Exemplo n.º 1
0
 public void Clear()
 {
     // 人物动画
     AnimationManager.GetInstance().RemoveAnimation(_aniChar);
     _aniChar          = null;
     _charAniSp.sprite = null;
     _charAniSp        = null;
     _isCastingBomb    = false;
     // B
     if (_bomb != null)
     {
         _bomb.Clear();
         _bomb = null;
     }
     // 副武器
     _subLayerTrans = null;
     for (int i = 0; i < _subWeapons.Length; i++)
     {
         _subWeapons[i].Clear();
     }
     _subWeapons = null;
     // 销毁
     GameObject.Destroy(_character);
     _character = null;
     // 判定点
     GameObject.Destroy(_collisionPointTf.gameObject);
     _collisionPointTf = null;
     _rotatePointTf    = null;
     // 状态机
     _stateEnterFunc  = null;
     _stateExitFunc   = null;
     _stateUpdateFunc = null;
 }
Exemplo n.º 2
0
 protected virtual void StateNormalUpdate()
 {
     OnFrameStarted();
     CheckMoveMode();
     Move();
     UpdateCD();
     Shoot();
     CastBomb();
     if (_isCastingBomb)
     {
         _bomb.Update();
         if (_bomb.IsFinish)
         {
             _isCastingBomb = false;
             _bomb.Clear();
             _bomb = null;
         }
     }
     UpdateSubWeapons();
     UpdateCollisionData();
     if (_isInvincible)
     {
         UpdateInvincibleStatus();
     }
     UpdatePosition();
     ResetExtraSpeedParas();
 }
Exemplo n.º 3
0
 void TouchPhaseEnded()
 {
     isMove = false;
     if (bombBase != default)
     {
         BombAnimationChatch();
     }
     bombBase = default;
 }
Exemplo n.º 4
0
 public void DestroyBomb(BombBase bombBase)
 {
     if (bombBase == null)
     {
         return;
     }
     bombBase.OnDeInit();
     m_bombs.Remove(bombBase);
     m_dicBombs.Remove(bombBase.gameObject.GetInstanceID());
     GameObject.Destroy(bombBase.gameObject);
 }
Exemplo n.º 5
0
 private void Start()
 {
     _touchManager  = new TouchManager();
     old_phase      = new TouchManager();
     isMove         = false;
     gameTopRight   = 1920 - 1920 / 20;
     gameBottomLeft = 1920f / 20f;
     gameTop        = 1080 - 1080 / 15;
     gameButtom     = 0;
     isCatch        = false;
     bombBase       = default;
 }
Exemplo n.º 6
0
 void TouchPhaseMoved()
 {
     //ボムをつかむまで
     if (bombBase == default)
     {
         float distance = 100; // 飛ばす&表示するRayの長さ
         float duration = 3;   // 表示期間(秒)
         Ray   ray      = Camera.main.ScreenPointToRay(AlmightyTapPosition());
         Debug.DrawRay(ray.origin, ray.direction * distance, Color.red, duration, false);
         RaycastHit hit = new RaycastHit();
         //ボムをつかんだ
         if (Physics.Raycast(ray, out hit, distance))
         {
             if (hit.collider.tag == "EnemyBomb")
             {
                 isMove   = true;
                 bombBase = hit.collider.gameObject.GetComponent <BombBase>();
                 BombAnimationChatch();
             }
         }
     }
     //クリックし続けてるなら
     if (isMove)
     {
         pos = _camera.ScreenToWorldPoint(AlmightyTapPosition() + _camera.transform.forward * 10);
         Vector3 fixPos = AlmightyTapPosition();
         if (CheckUIRect(0) == 1)
         {
             fixPos.x = EachPixel(1) + EachPixel(5);
         }
         else if (CheckUIRect(0) == 2)
         {
             fixPos.x = EachPixel(2) - EachPixel(5);
         }
         if (CheckUIRect(1) == 3)
         {
             fixPos.y = EachPixel(3) + EachPixel(6);
         }
         else if (CheckUIRect(1) == 4)
         {
             fixPos.y = EachPixel(4) - EachPixel(6);
         }
         fixPos.z = 0;
         pos      = _camera.ScreenToWorldPoint(fixPos + _camera.transform.forward * 10);
         bombBase.transform.position = pos;
         //Debug.Log(Input.mousePosition + "," + pos + "," + _camera.ScreenToWorldPoint(AlmightyTapPosition() + _camera.transform.forward * 10));
     }
 }
Exemplo n.º 7
0
        private async void AddNewBombToSystem(BombBase bomb, BombEnums.BombTypes type)
        {
            switch (type)
            {
            case BombEnums.BombTypes.RemoveMine:
                RemoteMines.Add((RemoteMine)bomb);
                if (Me.GetAbilityById(AbilityId.special_bonus_unique_techies_4).Level > 0)
                {
                    bomb.StartUpdatingPosition();
                }

                break;

            case BombEnums.BombTypes.StasisTrap:
                StasisTraps.Add((StasisTrap)bomb);
                break;

            case BombEnums.BombTypes.LandMine:
                LandMines.Add((LandMine)bomb);
                await Task.Delay(150);

                try
                {
                    if (AutoPlanter.IsAutoMovingToStaticTraps)
                    {
                        var closetStaticMine = StasisTraps.Where(x =>
                                                                 x.Owner.IsInRange(bomb.Owner, AutoPlanter.RangeForMinesAutoMoving.Value))
                                               .OrderBy(z => z.Owner.Distance2D(bomb.Owner)).FirstOrDefault();
                        if (closetStaticMine != null)
                        {
                            bomb.Owner.Move(closetStaticMine.Owner.Position, false, true);
//                                Me.Move(closetStaticMine.Owner.Position, false, true);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }


                break;
            }

            FullBombList.Add(bomb);
        }
Exemplo n.º 8
0
        public bool IsDrawEnabledForBombType(BombBase bombBase)
        {
            var bombName = bombBase.Owner.Name.Replace("npc_dota_", "");

            // var searchName = d.Key.Replace("_mines", "_mine");

            // foreach (var d in AbilityRangeToggle.GetValue(bombBase.))
            // {
            //     var bombName = bombBase.Owner.Name.Replace("npc_dota_", "");
            //     var searchName = d.Key.Replace("_mines", "_mine");
            //     if (bombName == searchName)
            //     {
            //         return d.Value;
            //     }
            // }

            return(true);
        }
Exemplo n.º 9
0
        private void RemoveBombFromSystem(BombBase bomb)
        {
            switch (bomb)
            {
            case RemoteMine mine:
                RemoteMines.Remove(mine);
                mine.DisposeSpawnRange();
                mine.UnStacker(RemoteMines);
                break;

            case StasisTrap trap:
                StasisTraps.Remove(trap);
                break;

            case LandMine mine:
                LandMines.Remove(mine);
                break;
            }

            FullBombList.Remove(bomb);
        }
Exemplo n.º 10
0
        public BombManager(Updater updater)
        {
            _updater = updater;

            FullBombList = new List <BombBase>();
            RemoteMines  = new List <RemoteMine>();
            StasisTraps  = new List <StasisTrap>();
            LandMines    = new List <LandMine>();

            var dict = new Dictionary <AbilityId, bool>
            {
                { AbilityId.techies_remote_mines, true },
                { AbilityId.techies_stasis_trap, true },
                { AbilityId.techies_land_mines, true }
            };

            AbilityRangeToggle = updater._main.MenuManager.RangeMenu.CreateAbilityToggler("Show range", dict);
            //TODO: проверить че за хуйня
            // var lastDict = AbilityRangeToggle.Values.ToDictionary(x => x.Key, z => z.Value);
            // AbilityRangeToggle.ValueChanged += (sender) =>
            // {
            //     foreach (var d in dict)
            //     {
            //         foreach (var f in lastDict)
            //         {
            //             if (f.Key != d.Key) continue;
            //             if (f.Value == d.Value) continue;
            //             foreach (var bombBase in FullBombList)
            //             {
            //                 var bombName = bombBase.Owner.Name.Replace("npc_dota_", "");
            //                 var searchName = d.Key.Replace("_mines", "_mine");
            //                 if (bombName == searchName)
            //                 {
            //                     bombBase.ChangeDrawType(d.Value,
            //                         bombBase is RemoteMine ? Color.Red : Color.White);
            //                 }
            //             }
            //         }
            //     }
            //
            //     // lastDict = AbilityRangeToggle.Value.Dictionary.ToDictionary(x => x.Key, z => z.Value);
            // };


            foreach (var unit in EntityManager.GetEntities <Unit>())
            {
                var bomb = FullBombList.Find(x => x.Owner.Handle == unit.Handle);
                if (bomb == null)
                {
                    var name = unit.Name;

                    BombBase bombBase = null;
                    switch (name)
                    {
                    case "npc_dota_techies_land_mine":
                        bombBase = new LandMine(unit).SetDamage(_updater._main.LandMine.GetDamage());
                        AddNewBombToSystem(bombBase, BombEnums.BombTypes.LandMine);
                        break;

                    case "npc_dota_techies_stasis_trap":
                        bombBase = new StasisTrap(unit, new CantDetonate());
                        AddNewBombToSystem(bombBase, BombEnums.BombTypes.StasisTrap);
                        break;

                    case "npc_dota_techies_remote_mine":
                        bombBase = new RemoteMine(unit).UpdateStacker(RemoteMines)
                                   .SetDamage(_updater._main.RemoteMine.GetDamage(), true);
                        AddNewBombToSystem(bombBase, BombEnums.BombTypes.RemoveMine);
                        break;
                    }

                    if (bombBase != null)
                    {
                        bombBase.IsActive = true;
                        bombBase.ChangeDrawType(true && IsDrawEnabledForBombType(bombBase),
                                                bombBase is RemoteMine ? Color.Red : Color.White);
                    }
                }
            }


            EntityManager.EntityAdded += (sender) =>
            {
                if (sender.IsCollection)
                {
                    return;
                }
                UpdateManager.BeginInvoke(0, () =>
                {
                    var unit = sender.Entity as Unit;
                    if (unit == null)
                    {
                        return;
                    }
                    var name = unit.Name;
                    switch (name)
                    {
                    case "npc_dota_techies_land_mine":
                        AddNewBombToSystem(new LandMine(unit).SetDamage(_updater._main.LandMine.GetDamage()),
                                           BombEnums.BombTypes.LandMine);
                        break;

                    case "npc_dota_techies_stasis_trap":
                        AddNewBombToSystem(new StasisTrap(unit, new CantDetonate()),
                                           BombEnums.BombTypes.StasisTrap);
                        break;

                    case "npc_dota_techies_remote_mine":
                        var bomb = new RemoteMine(unit).UpdateStacker(RemoteMines)
                                   .SetDamage(_updater._main.RemoteMine.GetDamage(), true);
                        AddNewBombToSystem(bomb,
                                           BombEnums.BombTypes.RemoveMine);
                        (bomb as RemoteMine)?.DrawSpawnRange();
                        break;
                    }
                });
            };

            EntityManager.EntityRemoved += (sender) =>
            {
                var unit = sender.Entity as Unit;
                if (unit == null)
                {
                    return;
                }
                var name = unit.Name;
                var bomb = FullBombList.Find(x => x.Owner.Handle == unit.Handle);
                if (bomb != null)
                {
                    RemoveBombFromSystem(bomb);
                }
            };

            Entity.NetworkPropertyChanged += (unit, args) =>
            {
                var propertyName = args.PropertyName;
                if (!propertyName.Equals("m_iHealth") && !propertyName.Equals("m_NetworkActivity") &&
                    !propertyName.Equals("m_iTaggedAsVisibleByTeam"))
                {
                    return;
                }
                UpdateManager.BeginInvoke(() =>
                {
                    var bomb = FullBombList.Find(x => x.Owner.Handle == unit.Handle);
                    if (bomb == null)
                    {
                        return;
                    }

                    if (propertyName == "m_iHealth")
                    {
                        if (args.NewValue.GetInt32() <= 0)
                        {
                            RemoveBombFromSystem(bomb);
                        }
                        if (args.NewValue.GetInt32() <= 150)
                        {
                            (bomb as RemoteMine)?.Owner.Spellbook.Spell1.Cast();
                        }
                    }
                    else if (propertyName == "m_NetworkActivity")
                    {
                        // Console.WriteLine(args.NewValue.GetInt32());
                        bomb.IsActive = args.NewValue.GetInt32() == (int)BombEnums.SpawnStatus.IsActive;
                        if (bomb.IsActive)
                        {
                            (bomb as RemoteMine)?.DisposeSpawnRange();
                            var isVisible = bomb.Owner.IsVisibleToEnemies;
                            bomb.ChangeDrawType(IsDrawEnabledForBombType(bomb),
                                                isVisible ? Color.Red : Color.White);
                            if (bomb is LandMine mine)
                            {
                                if (isVisible)
                                {
                                    mine.StartTimer();
                                }
                            }
                        }
                        else
                        {
                            bomb.ChangeDrawType(true && IsDrawEnabledForBombType(bomb), Color.Gray);
                        }
                    }

                    if (bomb is RemoteMine)
                    {
                        if (propertyName == "m_iTaggedAsVisibleByTeam")
                        {
                            var isVisible = (args.NewValue.GetInt32() & 15) == 14;
                            bomb.ChangeDrawType(true,
                                                isVisible ? Color.Red : Color.White);
                        }
                    }
                    else if (bomb is LandMine land)
                    {
                        if (propertyName == "m_iTaggedAsVisibleByTeam")
                        {
                            //UpdateManager.BeginInvoke(() =>
                            //{
                            land.BombStatus  = (BombEnums.BombStatus)args.NewValue.GetInt32();
                            var willDetonate = land.BombStatus == BombEnums.BombStatus.WillDetonate;
                            bomb.ChangeDrawType(true && IsDrawEnabledForBombType(bomb),
                                                willDetonate
                                    ? Color.Red
                                    : Color.White);

                            if (willDetonate)
                            {
                                land.StartTimer();
                            }
                            else
                            {
                                land.StopTimer();
                            }
                            //}, 25);
                        }
                    }
                });
            };


            UpdateManager.BeginInvoke(5000, async() =>
            {
                while (true)
                {
                    try
                    {
                        if (Me.GetAbilityById(AbilityId.special_bonus_unique_techies_4).Level > 0)
                        {
                            var list     = RemoteMines.ToList();
                            var tempList = new List <RemoteMine>();
                            foreach (var remoteMine in list)
                            {
                                remoteMine.Stacker.Counter = 0;
                            }

                            foreach (var remoteMine in list)
                            {
                                remoteMine.UpdateStacker(tempList);
                                tempList.Add(remoteMine);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    await Task.Delay(1000);
                }
            });
        }
Exemplo n.º 11
0
    protected override void OnUpdateState(float deltaTime, float unscaledDeltaTime, MemberState state)
    {
        switch (state)
        {
        case MemberState.Show:
            break;

        case MemberState.Idle:
        {
            var bombs = GameController.Builder.m_mapController.FindBombs(this.transform.position, 2);
            if (bombs.Count > 0)
            {
                // m_targetBomb = bombs[(int) Random.Range(0, bombs.Count)];

                m_time       = 0;
                m_targetBomb = bombs[0];

                if (m_targetBomb != null)
                {
                    PlayAgent();
                    Vector3 dir = m_targetBomb.transform.position - transform.position;
                    dir = new Vector3(dir.x, 0, dir.z);
                    dir = dir.normalized * 1;
                    Vector3 pos = new Vector3(m_targetBomb.transform.position.x, 0, m_targetBomb.transform.position.z);
                    SetAgentDestination(pos + dir);
                    SwtichState(MemberState.Run);
                }
            }
        }
        break;

        case MemberState.Run:
        {
            if (m_isWait)
            {
                m_time += deltaTime;
                if (m_time >= 0.5f)
                {
                    SwtichState(MemberState.Idle);
                    m_isWait = false;
                }
            }
            else
            {
                if (m_targetBomb != null)
                {
                    // if (Vector3.Distance(m_targetBomb.transform.position, GetAgentDestination()) >= 0.5f)
                    // {
                    //     SetAgentDestination(m_targetBomb.transform.position);
                    // }
                    m_time += deltaTime;
                    if (m_time >= 1)
                    {
                        SwtichState(MemberState.Idle);
                        m_isWait = false;
                        return;
                    }

                    Vector3 trans = new Vector3(transform.transform.position.x, 0, transform.transform.position.z);
                    if (Vector3.Distance(GetAgentDestination(), trans) <= 0.5f)
                    {
                        m_isWait = true;
                        StopAgent();
                    }
                }
                else
                {
                    m_isWait = true;
                    StopAgent();
                }
            }
        }
        break;

        case MemberState.Death:
            break;
        }
    }
Exemplo n.º 12
0
    void Update()
    {
        //タッチ情報更新
        _touchManager.update();
        _touchManager.GetTouch();
        if (_touchManager._touch_flag)
        {
            if (Application.isEditor)
            {
                // 座標系変換
                Vector3 pos = default;
                if (old_phase._touch_phase == TouchPhase.Began)
                {
                    // マウスのワールド座標までパーティクルを移動し、パーティクルエフェクトを1つ生成する
                    pos = _camera.ScreenToWorldPoint(Input.mousePosition + _camera.transform.forward * 10);
                }
                else if (_touchManager._touch_phase == TouchPhase.Moved)
                {
                    float distance = 100; // 飛ばす&表示するRayの長さ
                    float duration = 3;   // 表示期間(秒)
                    Ray   ray      = Camera.main.ScreenPointToRay(Input.mousePosition);
                    Debug.DrawRay(ray.origin, ray.direction * distance, Color.red, duration, false);
                    RaycastHit hit = new RaycastHit();
                    //ヒットボックスの存在するオブジェクトにRayが衝突したときの処理
                    if (Physics.Raycast(ray, out hit, distance))
                    {
                        isMove   = true;
                        bombBase = hit.collider.gameObject.GetComponent <BombBase>();
                    }
                    //クリックし続けてるなら
                    if (isMove)
                    {
                        //pos                :unity.transform.positionの座標
                        //Input.mousePosition:1920x1080のクリックした座標
                        pos = _camera.ScreenToWorldPoint(Input.mousePosition + _camera.transform.forward * 10);
                        if (_touchManager._touch_position.x < gameBottomLeft || _touchManager._touch_position.x > gameTopRight)
                        {
                            Debug.Log("範囲外 : " + "," + _touchManager._touch_position + "," + pos);
                            pos = new Vector3(oldPos.x, pos.y, pos.z);
                            //return;
                        }
                        if (_touchManager._touch_position.y > gameTop || _touchManager._touch_position.y < gameButtom)
                        {
                            Debug.Log("範囲外 : " + "," + _touchManager._touch_position + "," + pos);
                            pos = new Vector3(pos.x, oldPos.y, pos.z);
                            // return;
                        }
                        bombBase.transform.position = pos;
                    }
                }
                else if (_touchManager._touch_phase == TouchPhase.Ended)
                {
                    isMove = false;
                }
                oldPos = pos;
            }
            else
            {
                // 座標系変換
                Vector3 vPoint = _touchManager._touch_position;

                Vector3 pos = default;

                //クリックした瞬間
                if (_touchManager._touch_phase == TouchPhase.Began)
                {
                    // タップのワールド座標までパーティクルを移動し、パーティクルエフェクトを1つ生成する
                    pos = _camera.ScreenToWorldPoint(vPoint + _camera.transform.forward * 10);
                }
                //クリック長押し中(クリックした瞬間の次フレームから離すまでの間)
                else if (_touchManager._touch_phase == TouchPhase.Moved)
                {
                    float      distance = 100; // 飛ばす&表示するRayの長さ
                    Ray        ray      = Camera.main.ScreenPointToRay(vPoint);
                    RaycastHit hit      = new RaycastHit();
                    //ヒットボックス(HitBox3Dのみ、2Dには対応してないので別の書き方をする)の存在するオブジェクトにRayが衝突したときの処理^0^
                    if (Physics.Raycast(ray, out hit, distance))
                    {
                        isMove   = true;
                        bombBase = hit.collider.gameObject.GetComponent <BombBase>();
                    }
                    //クリックし続けてるなら
                    if (isMove)
                    {
                        pos = _camera.ScreenToWorldPoint(vPoint + _camera.transform.forward * 10);
                        if (vPoint.x < gameBottomLeft || vPoint.x > gameTopRight)
                        {
                            pos = new Vector3(oldPos.x, pos.y, pos.z);
                        }
                        if (vPoint.y > gameTop || vPoint.y < gameButtom)
                        {
                            pos = new Vector3(pos.x, oldPos.y, pos.z);
                        }
                        bombBase.transform.position = pos;
                    }
                }
                else if (_touchManager._touch_phase == TouchPhase.Ended)
                {
                    isMove = false;
                }
                oldPos = pos;
            }
            //oldの更新
            old_phase._touch_phase = _touchManager._touch_phase;

            if (bombBase != default)
            {
                bombBase.Catch(isMove);
            }
        }
    }