Beispiel #1
0
 void Die()
 {
     onDie = true;
     GetComponent <BoxCollider>().enabled = false;
     GetComponent <Monster>().enabled     = false;
     transform.Find("MonsterMove").gameObject.SetActive(false);
     transform.Find("MonsterAttack").gameObject.SetActive(false);
     transform.Find("HPFrame").gameObject.SetActive(false);
     _as.PlayOneShot(dieSound);
     Instantiate(effect1, transform.position, Quaternion.Euler(new Vector3(-90, 0f, 0f)));
     Instantiate(effect2, transform.position, Quaternion.Euler(new Vector3(-90, 0f, 0f)));
     MyTool.GetLocalPlayer().RemoveMonster(this);
 }
Beispiel #2
0
    void DestroyObject()
    {
        Vector3 newVec = transform.position;

        newVec.z = -4f;
        Instantiate(attackEffect, newVec, Quaternion.identity);
        if (MyTool.GetLocalPlayer().PlayerId == BulletTargetPlayer)
        {
            GetComponent <AudioSource>().PlayOneShot(destroySound);
        }
        GetComponent <SpriteRenderer>().enabled = false;
        GetComponent <SphereCollider>().enabled = false;
        GetComponent <BulletMain>().enabled     = false;
        Destroy(gameObject, 1f);
        onDestroy = true;
    }
Beispiel #3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         if (isServer)
         {
             if (isBig)
             {
                 other.gameObject.GetComponent <PlayerMain>().CmdAddMoney(bigMoneyValue);
             }
             else
             {
                 other.gameObject.GetComponent <PlayerMain>().CmdAddMoney(moneyValue);
             }
         }
         MyTool.GetLocalPlayer().GetComponent <AudioSource>().PlayOneShot(popCornGet);
         Destroy(gameObject);
     }
 }
Beispiel #4
0
    void RpcShoot(int playerId, Vector2 shootForce, Vector3 startPos)
    {
        if (isServer)
        {
            return;
        }
        _pa.RunShootAnimation();
        if (playerId == MyTool.GetLocalPlayer().PlayerId)
        {
            return;
        }
        var bulletObj = Instantiate(_pc.Bullet);

        bulletObj.transform.position   = startPos;
        bulletObj.transform.localScale = new Vector2((float)_pc.Damage * 0.02f, (float)_pc.Damage * 0.02f);
        bulletObj.GetComponent <BulletMain>().SetPlayerId(playerId);
        bulletObj.GetComponent <Rigidbody>().velocity = shootForce * _pc.ShootPower;
        bulletObj.GetComponent <BulletMain>().damage  = _pc.Damage;
        Destroy(bulletObj, 10.0f);
    }
Beispiel #5
0
    void Start()
    {
        _as = GetComponent <AudioSource>();
        _as.PlayOneShot(startSound);
        playerTransforms = new List <Transform>();
        var players = GameObject.FindObjectsOfType <PlayerMain>();

        foreach (var player in players)
        {
            playerTransforms.Add(player.transform);
        }
        _hp = _maxHp;
        _rb = GetComponent <Rigidbody>();
        MyTool.GetLocalPlayer().AddMonster(this);
        MyTool.GetLocalPlayer().CalcPos(this);
        RefreshHp();
        move   = transform.Find("MonsterMove").gameObject;
        attack = transform.Find("MonsterAttack").gameObject;
        move.SetActive(true);
        attack.SetActive(false);
    }
Beispiel #6
0
    public bool Use()
    {
        if (coolTimeTimer > 0.001f)
        {
            return(false);
        }
        int beforePrice = GetPrice();

        switch (stuffType)
        {
        case StuffType.POWER:
        {
            if (upgradeCount >= 5)
            {
                return(false);
            }
            string newText = "공격력 강화";
            upgradeCount += 1;
            if (upgradeCount >= 1)
            {
                newText = newText + " +" + upgradeCount;
            }
            nameText.text  = newText;
            priceText.text = GetPrice() + " PC";
            if (upgradeCount >= 5)
            {
                priceText.text = "";
                panel.gameObject.SetActive(true);
            }
        }
        break;

        case StuffType.HP:
        {
            if (upgradeCount >= 5)
            {
                return(false);
            }
            string newText = "방어력 강화";
            upgradeCount += 1;
            if (upgradeCount >= 1)
            {
                newText = newText + " +" + upgradeCount;
            }
            nameText.text  = newText;
            priceText.text = GetPrice() + " PC";
            if (upgradeCount >= 5)
            {
                priceText.text = "";
                panel.gameObject.SetActive(true);
            }
        }
        break;

        case StuffType.BOMB:
            StartCoolTime();
            break;

        case StuffType.SPEED:
            StartCoolTime();
            break;

        case StuffType.ATTACK_SPEED:
            StartCoolTime();
            break;
        }
        var effect = Instantiate(stuffEffect, GameObject.Find("Canvas").transform);

        effect.GetComponent <UnityEngine.UI.Image>().sprite = transform.Find("IM_Image").GetComponent <UnityEngine.UI.Image>().sprite;
        effect.transform.Find("TX_Price").GetComponent <UnityEngine.UI.Text>().text = beforePrice + " PC";
        MyTool.GetLocalPlayer().GetComponent <AudioSource>().PlayOneShot(shopSound);
        StartAllShortCoolTime();
        return(true);
    }