コード例 #1
0
    private void Update()
    {
        if (!transform.parent.CompareTag("Player"))
        {
            return;
        }
        if (Btn1 || Btn2 || Btn3)
        {
            Cursor_Manager.m_Cursor_Manager.SetCursor(_UI.Cursors[0]);
        }
        if (Input.GetMouseButtonDown(0))
        {
            if (Btn1 || Btn2 || Btn3)
            {
                Vector2      pos = _Input.pos;
                RaycastHit2D hit = _Input.hit_Player;

                if (hit.transform != null && hit.transform.tag == "Enemy")
                {
                    Unit_Manager _Unit = hit.transform.GetComponent <Unit_Manager>();
                    if (Mathf.Abs(_Unit.x - Unit.x) + Mathf.Abs(_Unit.y - Unit.y) <= Range)
                    {
                        if (Btn1)
                        {
                            _Unit.Hit(this);
                            Bullet--;
                            _UI._Clip.text = Bullet.ToString();
                            Aim_Bonus      = 0;
                        }
                        else if (Btn2)
                        {
                            StartCoroutine(_BTN2(_Unit));
                        }
                        else
                        {
                            _Unit.Hit(this);
                            Bullet--;
                            _UI._Clip.text = Bullet.ToString();
                            Aim_Bonus      = 0;
                        }

                        if (Btn2)
                        {
                            Unit.Now_Action_Point -= 2;
                        }
                        Unit.Now_Action_Point -= 3;


                        Action = false;
                        Btn1   = false;
                        Btn3   = false;
                        Cursor_Manager.m_Cursor_Manager.SetCursor(_UI.Cursors[1]);
                        Unit.DrawActionPoint();
                    }
                }
            }
        }
    }
コード例 #2
0
    public override bool Rand(Unit_Manager _Unit)
    {
        base.Rand(_Unit);

        if (Bullet >= 1 && Unit.Now_Action_Point >= 6)
        {
            switch (Random.Range(1, 3))
            {
            case 1:
                BTN1();
                break;

            case 2:
                BTN2();
                break;
            }
        }
        else if (Bullet >= 1 && Unit.Now_Action_Point >= 3)
        {
            BTN1();
        }
        else if (Unit.Now_Action_Point >= 3)
        {
            BTN3();
        }
        else
        {
            return(false);
        }

        if (Btn1 || Btn2)
        {
            if (Mathf.Abs(_Unit.x - Unit.x) - Mathf.Abs(_Unit.y - Unit.y) <= Range)
            {
                _Unit.Hit(this);
                Action = false;

                if (Btn2)
                {
                    Unit.Now_Action_Point -= 3;
                }
                Unit.Now_Action_Point -= 3;

                Btn2 = false;
                Btn1 = false;

                Bullet--;
                Aim_Bonus = 0;
            }
            else
            {
                Unit.Now_Action_Point = 0;
            }
        }

        return(true);
    }
コード例 #3
0
 IEnumerator _BTN3(Unit_Manager _Unit)
 {
     for (int i = 0; i < 50; i++)
     {
         if (_Unit != null)
         {
             _Unit.Hit(this);
             Bullet--;
             _UI._Clip.text = Bullet.ToString();
         }
         yield return(new WaitForSeconds(0.1f));
     }
     Aim_Bonus = 0;
     Action    = false;
     Btn3      = false;
 }
コード例 #4
0
    IEnumerator _BTN4(Unit_Manager _Unit, int _Bullet)
    {
        for (int i = 0; i < _Bullet; i++)
        {
            if (i >= 20)
            {
                break;
            }

            if (_Unit != null)
            {
                _Unit.Hit(this);
                Bullet--;
                _UI._Clip.text = Bullet.ToString();
            }
            yield return(new WaitForSeconds(0.1f));
        }
        Aim_Bonus = 0;
        Action    = false;
        Btn4      = false;
        yield return(null);
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        if (!transform.parent.CompareTag("Player"))
        {
            return;
        }
        Vector2      pos = _Input.pos;
        RaycastHit2D hit = _Input.hit_Tile;


        if (Btn1)
        {
            if (Input_Manager.Highlighted != null)
            {
                Input_Manager.Highlighted();
                Input_Manager.Highlighted = null;
            }
            Cursor_Manager.m_Cursor_Manager.SetCursor(UI_MANAGER.m_UI_MANAGER.Cursors[0]);



            if (hit.transform != null && hit.transform.tag == "Tile")
            {
                Tile _Tile = hit.transform.GetComponent <Tile>();

                if (Mathf.Abs(_Tile.X - Unit.x) + Mathf.Abs(_Tile.Y - Unit.y) <= Weapon.Range)
                {
                    for (int x = _Tile.X - 1; x <= _Tile.X + 1; x++)
                    {
                        if (x < 0 || x >= Tile_Manager.m_Tile_Manager.X)
                        {
                            continue;
                        }
                        for (int y = _Tile.Y - 1; y <= _Tile.Y + 1; y++)
                        {
                            if (y < 0 || y >= Tile_Manager.m_Tile_Manager.Y)
                            {
                                continue;
                            }
                            if (x != _Tile.X && y != _Tile.Y)
                            {
                                continue;
                            }

                            Tile N_Tile = Tile_Manager.m_Tile_Manager.MY_Tile[x][y];

                            N_Tile.HighLight(1);
                        }
                    }
                }
            }
        }
        if (Input.GetMouseButtonDown(0))
        {
            if (Btn1)
            {
                if (hit.transform != null && hit.transform.tag == "Tile")
                {
                    Tile _Tile = hit.transform.GetComponent <Tile>();

                    if (Mathf.Abs(_Tile.X - Unit.x) + Mathf.Abs(_Tile.Y - Unit.y) <= Weapon.Range)
                    {
                        for (int x = _Tile.X - 1; x <= _Tile.X + 1; x++)
                        {
                            for (int y = _Tile.Y - 1; y <= _Tile.Y + 1; y++)
                            {
                                Weapon.HeadShot_Bonus = 0;
                                if (x < 0 || x >= _Tile._Tile.X || y < 0 || y >= _Tile._Tile.Y)
                                {
                                    continue;
                                }
                                if (x != _Tile.X && y != _Tile.Y)
                                {
                                    continue;
                                }

                                _Tile._Tile.MY_Tile[x][y].DownGrade();

                                if (_Tile._Tile.MY_Tile[x][y].transform.childCount > 0)
                                {
                                    if (_Tile._Tile.MY_Tile[x][y].transform.Find("Enemy(Clone)") != null)
                                    {
                                        Unit_Manager _Unit = _Tile._Tile.MY_Tile[x][y].transform.Find("Enemy(Clone)").GetComponent <Unit_Manager>();
                                        if (_Unit != null)
                                        {
                                            if (x == _Tile.X && y == _Tile.Y)
                                            {
                                                Weapon.HeadShot_Bonus = 100;
                                            }

                                            _Unit.Hit(Weapon);
                                        }
                                    }
                                    else if (_Tile._Tile.MY_Tile[x][y].transform.Find("Player(Clone)") != null)
                                    {
                                        Unit_Manager _Unit = _Tile._Tile.MY_Tile[x][y].transform.Find("Player(Clone)").GetComponent <Unit_Manager>();
                                        if (_Unit != null)
                                        {
                                            if (x == _Tile.X && y == _Tile.Y)
                                            {
                                                Weapon.HeadShot_Bonus = 100;
                                            }

                                            _Unit.Hit(Weapon);
                                        }
                                    }
                                }
                            }
                        }

                        Unit.Tile_InSighted = null;
                        Unit.View.InView();

                        Unit.Now_Action_Point -= 3;
                        Unit.DrawActionPoint();

                        Btn1   = false;
                        Action = false;
                        count--;

                        Cursor_Manager.m_Cursor_Manager.SetCursor(UI_MANAGER.m_UI_MANAGER.Cursors[1]);

                        if (count <= 0)
                        {
                            Unit.Items.Remove(this);
                            Unit.Select();
                            Destroy(gameObject);
                        }
                    }
                }
            }
        }
    }
コード例 #6
0
    public override bool Rand(Enemy_Manager _this)
    {
        base.Rand(_this);
        if (Unit.Now_Action_Point < 3 || Action)
        {
            return(false);
        }

        Unit_Manager CloserPlayer = _this.GetMeetPlayer()[_this.CloserPlayer()];

        if (Mathf.Abs(CloserPlayer.x - _this.x) + Mathf.Abs(CloserPlayer.y - _this.y) <= Weapon.Range)
        {
            Tile _Tile = CloserPlayer.T;

            for (int x = _Tile.X - 1; x <= _Tile.X + 1; x++)
            {
                for (int y = _Tile.Y - 1; y <= _Tile.Y + 1; y++)
                {
                    Weapon.HeadShot_Bonus = 0;
                    if (x < 0 || x >= _Tile._Tile.X || y < 0 || y >= _Tile._Tile.Y)
                    {
                        continue;
                    }
                    if (x != _Tile.X && y != _Tile.Y)
                    {
                        continue;
                    }

                    _Tile._Tile.MY_Tile[x][y].DownGrade();

                    if (_Tile._Tile.MY_Tile[x][y].transform.childCount > 0)
                    {
                        if (_Tile._Tile.MY_Tile[x][y].transform.Find("Enemy(Clone)") != null)
                        {
                            Unit_Manager _Unit = _Tile._Tile.MY_Tile[x][y].transform.Find("Enemy(Clone)").GetComponent <Unit_Manager>();
                            if (_Unit != null)
                            {
                                if (x == _Tile.X && y == _Tile.Y)
                                {
                                    Weapon.HeadShot_Bonus = 100;
                                }

                                _Unit.Hit(Weapon);
                            }
                        }
                        else if (_Tile._Tile.MY_Tile[x][y].transform.Find("Player(Clone)") != null)
                        {
                            Unit_Manager _Unit = _Tile._Tile.MY_Tile[x][y].transform.Find("Player(Clone)").GetComponent <Unit_Manager>();
                            if (_Unit != null)
                            {
                                if (x == _Tile.X && y == _Tile.Y)
                                {
                                    Weapon.HeadShot_Bonus = 100;
                                }

                                _Unit.Hit(Weapon);
                            }
                        }
                    }
                }
            }

            _this.Now_Action_Point -= 3;

            Btn1   = false;
            Action = false;
            count--;

            Cursor_Manager.m_Cursor_Manager.SetCursor(UI_MANAGER.m_UI_MANAGER.Cursors[1]);

            if (count <= 0)
            {
                _this.Items.Remove(this);
                Destroy(gameObject);
            }
        }
        return(true);
    }
コード例 #7
0
    public override bool Rand(Unit_Manager _Unit)
    {
        base.Rand(_Unit);

        if (Bullet >= 3 && Unit.Now_Action_Point >= 5)
        {
            switch (Random.Range(1, 4))
            {
            case 1:
                BTN1();
                break;

            case 2:
                BTN2();
                break;

            case 3:
                BTN3();
                break;
            }
        }
        else if (Bullet > 0 && Unit.Now_Action_Point >= 3)
        {
            switch (Random.Range(1, 3))
            {
            case 1:
                BTN1();
                break;

            case 2:
                BTN3();
                break;
            }
        }
        else if (Unit.Now_Action_Point >= 3)
        {
            BTN4();
        }
        else
        {
            return(false);
        }

        if (Btn1 || Btn2 || Btn3)
        {
            if (Mathf.Abs(_Unit.x - Unit.x) - Mathf.Abs(_Unit.y - Unit.y) <= Range)
            {
                if (Btn1)
                {
                    _Unit.Hit(this);
                    Bullet--;
                    _UI._Clip.text = Bullet.ToString();
                    Aim_Bonus      = 0;
                }
                else if (Btn2)
                {
                    StartCoroutine(_BTN2(_Unit));
                }
                else
                {
                    _Unit.Hit(this);
                    Bullet--;
                    _UI._Clip.text = Bullet.ToString();
                    Aim_Bonus      = 0;
                }

                if (Btn2)
                {
                    Unit.Now_Action_Point -= 2;
                }
                Unit.Now_Action_Point -= 3;


                Action = false;
                Btn1   = false;
                Btn3   = false;
            }
            else
            {
                Unit.Now_Action_Point = 0;
            }
        }
        return(true);
    }