Beispiel #1
0
    public override bool die()
    {
        deathMaterial.SetFloat("_Period", deathTime);
        deathMaterial.SetFloat("_StartTime", Time.fixedTime);
        var ren = transform.GetComponentsInChildren <Renderer>();

        foreach (var r in ren)
        {
            r.material = deathMaterial;
        }
        //GetComponent<Renderer>().material = deathMaterial;
        if (RightWeapon != null)
        {
            RightWeapon.DropWeapon();
        }
        if (LeftWeapon != null)
        {
            LeftWeapon.DropWeapon();
        }
        if (rb != null)
        {
            rb.Sleep();
        }
        if (isEDF)
        {
            GetComponent <CapsuleCollider>().enabled = false;
        }
        Destroy(gameObject, deathTime);
        this.enabled = false;
        return(true);//base.die();
    }
Beispiel #2
0
 /// <summary>
 /// <paramref name="picked"/>を拾う
 /// </summary>
 /// <param name="picked">拾うWeapon</param>
 public void PickUpWeapon(Weapon picked)
 {
     //枠がいっぱいなら手持ちと交換
     if (WeaponList.Count >= 2)
     {
         int index = WeaponList.FindIndex(match => RightWeapon == match);
         WeaponList[index] = picked;
         RightWeapon.DropWeapon();
         picked.HaveWeapon();
         RightWeapon = picked;
     }
     //何も持ってなかったらすぐ装備
     else if (RightWeapon == null && WeaponList.Count < 2)
     {
         WeaponList.Add(picked);
         picked.HaveWeapon();
         RightWeapon = picked;
         if (LeftWeapon != null)
         {
             LeftWeapon.isHave = false;
         }
     }
     //何か持ってて枠が空いてたら装備せずに拾う
     else if (RightWeapon != null && WeaponList.Count < 2)
     {
         WeaponList.Add(picked);
         picked.PickWeapon();
     }
     uiController.SlotUpdate(WeaponList);
     uiController.SetActiveSlot(WeaponList.FindIndex(m => m == RightWeapon));
 }
Beispiel #3
0
        private void GenerateTempWeapons()
        {
            var wp = Resources.Load <GameObject>("Weapons/FixedMachineGun");

            LeftWeapon = Instantiate(wp, transform).GetComponent <IWeaponTopDown>();
            LeftWeapon.SetTip(new Vector3(-0.4f, 0, 0.2f));

            RightWeapon = Instantiate(wp, transform).GetComponent <IWeaponTopDown>();
            RightWeapon.SetTip(new Vector3(0.4f, 0, 0.2f));
        }
Beispiel #4
0
    public void Init(Minion minion, bool isEnemy, LeftWeapon leftWeapon = null, RightWeapon rightWeapon = null)
    {
        ManaCost  = minion.ManaCost;
        Attack    = minion.Attack;
        Hp        = minion.Hp;
        MoveSpeed = minion.MoveSpeed;
        KnockBack = minion.Knockback;

        _leftVector  = Vector2.left * Time.deltaTime * MoveSpeed;
        _rightVector = Vector2.right * Time.deltaTime * MoveSpeed;

        // _attackReach = minion.AttackReach;

        IsEnemy = isEnemy;

        if (isEnemy)
        {
            return;
        }

        var sprite = GetComponentsInChildren <SpriteRenderer>();

        sprite[0].sprite = minion.Artwork;

        if (leftWeapon != null)
        {
            sprite[1].sprite = leftWeapon.Artwork;

            if (rightWeapon != null)
            {
                sprite[2].sprite = rightWeapon.Artwork;
            }

            // 왼손 무기 확인
            if (leftWeapon.Id != 0)
            {
                Attack    += leftWeapon.AddAttack;
                KnockBack += leftWeapon.AddKnockback;
                ManaCost  += leftWeapon.AddManaCost;
            }
        }

        // 오른손 무기 확인
        if (rightWeapon == null || rightWeapon.Id == 0)
        {
            return;
        }

        Hp        += rightWeapon.AddHp;
        MoveSpeed += rightWeapon.AddMoveSpeed;
        KnockBack += rightWeapon.AddKnockBack;
        ManaCost  += rightWeapon.AddManaCost;
    }
Beispiel #5
0
    /// <summary>
    /// 武器を持ち替える
    /// </summary>
    /// <param name="sign">持ち替える方向(正負)</param>
    public void ChangeWeapon(int sign)
    {
        if (NowWeapon == WEAPON_LEFT)
        {
            SwitchWeapon();
        }
        var nowIndex = WeaponList.FindIndex(match => match == RightWeapon);

        if (WeaponList.Count >= 2)
        {
            Weapon will;
            if (sign > 0 && nowIndex + 1 >= WeaponList.Count)
            {
                will = WeaponList[0];
            }
            else if (sign > 0 && nowIndex + 1 < WeaponList.Count)
            {
                will = WeaponList[nowIndex + 1];
            }
            else if (sign < 0 && nowIndex <= 0)
            {
                will = WeaponList[WeaponList.Count - 1];
            }
            else if (sign < 0 && nowIndex > 0)
            {
                will = WeaponList[nowIndex - 1];
            }
            else
            {
                will = WeaponList[0];
            }
            //debugText(WeaponList[nowIndex].ToString() +":::"+ Time.time.ToString());
            RightWeapon.ChangeWeapon();
            will.HaveWeapon();
            RightWeapon = will;
        }

        uiController.SlotUpdate(WeaponList);
        uiController.SetActiveSlot(WeaponList.FindIndex(m => m == RightWeapon));
    }
Beispiel #6
0
    // Update is called once per frame
    void Update()
    {
        time += Time.deltaTime;
        if (time >= cycle)
        {
            time   = 0.0f;
            wayFlg = 1 - wayFlg;
        }
        if (wayFlg == 0)
        {
            move(moveVec, 1);
        }
        else if (wayFlg == 1)
        {
            move(-moveVec, 1);
        }

        if (target != null)
        {
            //targetの方向を向く
            if (RightWeapon != null)
            {
                var len_xz = target.transform.position - RightWeapon.ShotTransform.position;
                //len_xz.y = 0;
                //debugText(len_xz.magnitude.ToString());
                if (len_xz.magnitude > (RightWeapon.ShotTransform.position - transform.position).magnitude * 1.5f)
                {
                    transform.rotation = Quaternion.LookRotation(target.transform.position - RightWeapon.ShotTransform.position);
                }
                else
                {
                }


                //targetの方向に動く
                if (isEDF)
                {
                    //オブジェクトの固有ナンバーからどっちに動くか判断
                    UnityEngine.Random.InitState(gameObject.GetHashCode());
                    var len = target.transform.position - RightWeapon.ShotTransform.position;
                    if (len.magnitude > 75)
                    {
                        move(new Vector3(UnityEngine.Random.value * 8 - 4, 0, (float)Math.Sqrt(len.magnitude) / 50), 1.6f);
                    }
                    else
                    {
                        move(new Vector3((UnityEngine.Random.value * 5 - 2.5f)
                                         , UnityEngine.Random.Range(-1, 1) * 0.2f, 0), 1.6f);
                    }
                }
            }
            else
            {
                transform.rotation = Quaternion.LookRotation(target.transform.position - transform.position);
            }
        }



        if (RightWeapon != null && target != null)
        {
            delayCnt++;
            if (delayCnt >= delay)
            {
                delayCnt = 0;

                //Raycastを使って向いてる方向に障害物がないかチェックして撃つ
                int        layerMask = 3 << 9;
                RaycastHit hit;
                if (Physics.Raycast(RightWeapon.ShotTransform.position, RightWeapon.ShotTransform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity) && ((hit.point - target.transform.position).magnitude <= 10 || (hit.collider.gameObject != null && hit.collider.gameObject.layer == 9)))
                {
                    //Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
                    RightWeapon.Fire1();
                }
                else
                {
                    //Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.white);
                }
            }
        }
    }
Beispiel #7
0
 private void ShootRHold()
 {
     RightWeapon.Use(transform.forward);
 }