Project_WL/Assets/Script/DropItem/DropItem.cs

153 lines
5.4 KiB
C#

using CodeStage.AntiCheat.ObscuredTypes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DropItem : ProjectileBase
{
public Collider m_Collider;
ObscuredInt _itemid;
int m_itemid
{
get { return _itemid; }
set { _itemid = value; _itemid.RandomizeCryptoKey(); }
}
ObscuredInt _itemamount;
int m_itemamount
{
get { return _itemamount; }
set { _itemamount = value; _itemamount.RandomizeCryptoKey(); }
}
int m_Magnet;
float MagnetUpTime = 0f;
Vector3 v3_MagnetUP;
private void Update()
{
switch (m_Magnet)
{
case 1:
if (MyValue.MyPC.IsDead())
m_Magnet = 0;
else
{
MagnetUpTime += Time.deltaTime * 2f;
transform.position = Vector3.MoveTowards(transform.position, v3_MagnetUP, Time.deltaTime * m_ProjecTileData.Speed);
if (MagnetUpTime >= 1f)
{
MagnetUpTime = 0f;
m_Magnet = 2;
m_ProjecTileData.Speed = 15f;
}
}
break;
case 2:
if (MyValue.MyPC.IsDead())
m_Magnet = 0;
else
{
m_ProjecTileData.Speed += Time.deltaTime * 2f;
transform.position = Vector3.MoveTowards(transform.position, MyValue.MyPC.Get_Center_position(), Time.deltaTime * m_ProjecTileData.Speed);
}
break;
}
}
public void Set(int itemid, int amount, Vector3 startpos)
{
gameObject.SetActive(true);
m_itemid = itemid;
m_itemamount = amount;
Vector3 targetpos = startpos;
switch (m_itemid)
{
case 2:
startpos += Vector3.up * 0.25f;
targetpos = DSUtil.Get_RandomPos_onNavMesh(startpos, 2f, 3f);
targetpos += Vector3.up * 0.25f;
break;
}
m_Collider.enabled = false;
StartCoroutine(Co_Move_Split(() =>
{
m_Collider.enabled = true;
if (m_Magnet == 0)
{
var sdata = ServerInfo.Ins.m_ServerData;
// TODO 정인호 : 컨텐츠에서 자석 기능이 있었는 데 어떻게 될 지 모르니 일단 주석처리
//if (InGameInfo.Ins.Get_CurStageData().Chapter > 100)
//{
// var costume16 = sdata.PC.Get_Value(16); // 코스튬 16
// if (costume16 > 0f && Vector3.Distance(transform.position, MyValue.MyPC.Get_position()) <= costume16)
// {
// m_Magnet = 1;
// v3_MagnetUP = transform.position + Vector3.up * 3f;
// m_ProjectTileData.Speed = 5f;
// }
//}
}
}, startpos, targetpos));
StartCoroutine(Co_Rotation_Y());
StartCoroutine(Co_Off(20f));
}
public bool ItemTouch(Actor touchActor)
{
if (gameObject.activeInHierarchy && touchActor)
{
if (touchActor.IsRole(eRole.PC) || touchActor.IsRole(eRole.Worker))
{
var sdata = ServerInfo.Ins.m_ServerData;
var statdata = touchActor.Get_StatInfo();
if (MyValue.MyChoiceMapData.Get_MapData().e_Dungeon == eDungeon.d4_Wave)
{
DungeonInfo.Ins.Add_WaveScore(1); // TODO 정인호 : 웨이브 점수
DungeonInfo.Ins.Add_WaveGold(10); // TODO 정인호 : 웨이브 골드
}
else
{
if (m_itemid == 2)
{
m_itemamount += (int)statdata.Get_Stat(eStat.GOLD_INCREASE);
m_itemamount += (int)(m_itemamount *
(statdata.Get_Stat(eStat.GOLD_Multiplier) + statdata.Get_Stat(eStat.Battle_GOLD_Multiplier)));
var GoldDropRandomRange = table_GlobalValue.Ins.Get_Float("GoldDropRandomRange");
var mingold = m_itemamount - (int)(m_itemamount * GoldDropRandomRange);
var maxgold = m_itemamount + (int)(m_itemamount * GoldDropRandomRange);
m_itemamount = Random.Range(mingold, maxgold);
}
sdata.Add_Item(m_itemid, _itemamount);
DropItemInfo.Ins.m_StageDropData.Add_Item(_itemid, m_itemamount);
}
InGameInfo.Ins.Show_Effect("Effect_GetCoin", transform.position);
gameObject.SetActive(false);
//NewGameUI.Ins.m_GuideQuestUI.Add_GuideQuest(ePurpose.GetDropItem);
return true;
}
}
return false;
}
public override bool ProcessCollider(Collider other, bool Off_byHit = true, bool noDmg = false)
{
return ItemTouch(other.GetComponent<Actor>());
}
IEnumerator Co_Rotation_Y()
{
float t = 0f;
while (true)
{
t += Time.deltaTime * 30f;
t = Mathf.Repeat(t, 359.9f);
transform.eulerAngles = new Vector3(0f, t, 0f);
yield return null;
}
}
}