Example #1
0
        public virtual void SetAction()
        {
            if (ActionFeed.Count == 0)
            {
                if (CMain.Random.Next(2) == 0 && Frames.Count > 1)
                {
                    CurrentAction = MirAction.Harvest;
                }
                else
                {
                    CurrentAction = MirAction.Standing;
                }

                Frames.TryGetValue(CurrentAction, out Frame);
                FrameIndex       = 0;
                EffectFrameIndex = 0;

                if (MapLocation != CurrentLocation)
                {
                    GameScene.Scene.MapControl.RemoveObject(this);
                    MapLocation = CurrentLocation;
                    GameScene.Scene.MapControl.AddObject(this);
                }

                if (Frame == null)
                {
                    return;
                }

                FrameInterval       = Frame.Interval;
                EffectFrameInterval = Frame.EffectInterval;
            }
            else
            {
                QueuedAction action = ActionFeed[0];
                ActionFeed.RemoveAt(0);

                CurrentAction   = action.Action;
                CurrentLocation = action.Location;

                //if(CanChangeDir)
                //    Direction = action.Direction;

                FrameIndex       = 0;
                EffectFrameIndex = 0;

                if (Frame == null)
                {
                    return;
                }

                FrameInterval       = Frame.Interval;
                EffectFrameInterval = Frame.EffectInterval;
            }

            NextMotion  = CMain.Time + FrameInterval;
            NextMotion2 = CMain.Time + EffectFrameInterval;

            GameScene.Scene.MapControl.TextureValid = false;
        }
Example #2
0
    public override void SetAction()
    {
        if (ActionFeed.Count == 0)
        {
            if (Dead)
            {
                CurrentAction = MirAction.Dead;
            }
            else
            {
                CurrentAction = MirAction.Standing;
            }
        }
        else
        {
            QueuedAction action = ActionFeed[0];
            ActionFeed.RemoveAt(0);

            CurrentAction            = action.Action;
            Direction                = action.Direction;
            Model.transform.rotation = ClientFunctions.GetRotation(Direction);

            switch (CurrentAction)
            {
            case MirAction.Walking:
            case MirAction.Running:
                int steps = 1;
                if (CurrentAction == MirAction.Running)
                {
                    steps = 2;
                }

                Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position;
                TargetPosition = targetpos;

                Vector2 back = ClientFunctions.Back(action.Location, Direction, steps);
                gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position;

                GameManager.CurrentScene.Cells[CurrentLocation.x, CurrentLocation.y].RemoveObject(this);
                GameManager.CurrentScene.Cells[action.Location.x, action.Location.y].AddObject(this);

                StartPosition  = gameObject.transform.position;
                TargetDistance = Vector3.Distance(transform.position, targetpos);
                IsMoving       = true;
                break;
            }

            CurrentLocation = action.Location;
        }

        GetComponentInChildren <Animator>().SetInteger("CurrentAction", (int)CurrentAction);
    }
Example #3
0
        public override void SetAction()
        {
            if (QueuedAction != null)
            {
                if ((ActionFeed.Count == 0) || (ActionFeed.Count == 1 && NextAction.Action == MirAction.Stance))
                {
                    ActionFeed.Clear();
                    ActionFeed.Add(QueuedAction);
                    QueuedAction = null;
                }
            }

            base.SetAction();
        }
Example #4
0
    public override void SetAction()
    {
        if (this == GameManager.User.Player && Time.time > GameManager.NextAction && GameScene.QueuedAction != null)
        {
            ActionFeed.Clear();
            ActionFeed.Add(GameScene.QueuedAction);
            GameScene.QueuedAction = null;
        }

        if (ActionFeed.Count == 0)
        {
            if (Dead)
            {
                CurrentAction = MirAction.Dead;
            }
            else
            {
                CurrentAction = MirAction.Standing;
            }
        }
        else
        {
            if (this == GameManager.User.Player && Time.time < GameManager.NextAction)
            {
                return;
            }
            QueuedAction action = ActionFeed[0];
            ActionFeed.RemoveAt(0);

            CurrentAction            = action.Action;
            Direction                = action.Direction;
            Model.transform.rotation = ClientFunctions.GetRotation(Direction);

            switch (CurrentAction)
            {
            case MirAction.Walking:
            case MirAction.Running:
                int steps = 1;
                if (CurrentAction == MirAction.Running)
                {
                    steps = 2;
                }

                Vector3 targetpos = GameManager.CurrentScene.Cells[action.Location.x, action.Location.y].position;
                TargetPosition = targetpos;

                if (this != GameManager.User.Player)
                {
                    Vector2Int back = ClientFunctions.Back(action.Location, Direction, steps);
                    gameObject.transform.position = GameManager.CurrentScene.Cells[back.x, back.y].position;
                }

                GameManager.CurrentScene.Cells[CurrentLocation.x, CurrentLocation.y].RemoveObject(this);
                GameManager.CurrentScene.Cells[action.Location.x, action.Location.y].AddObject(this);

                StartPosition  = gameObject.transform.position;
                TargetDistance = Vector3.Distance(transform.position, targetpos);
                IsMoving       = true;

                RefreshSounds();
                break;
            }

            CurrentLocation = action.Location;

            Spell = Spell.None;

            if (this == GameManager.User.Player)
            {
                switch (CurrentAction)
                {
                case MirAction.Standing:
                    Network.Enqueue(new C.Turn {
                        Direction = action.Direction
                    });
                    GameManager.NextAction  = Time.time + 2.5f;
                    GameManager.InputDelay  = Time.time + 0.5f;
                    GameManager.User.CanRun = false;
                    break;

                case MirAction.Walking:
                    Network.Enqueue(new C.Walk {
                        Direction = action.Direction
                    });
                    GameManager.NextAction       = Time.time + 2.5f;
                    GameManager.InputDelay       = Time.time + 0.5f;
                    GameManager.User.LastRunTime = Time.time;
                    GameManager.User.CanRun      = true;
                    break;

                case MirAction.Running:
                    Network.Enqueue(new C.Run {
                        Direction = action.Direction
                    });
                    GameManager.NextAction       = Time.time + 2.5f;
                    GameManager.InputDelay       = Time.time + 0.5f;
                    GameManager.User.LastRunTime = Time.time;
                    break;

                case MirAction.Attack:
                    if (GameScene.Slaying && GameScene.TargetObject != null)
                    {
                        Spell             = Spell.Slaying;
                        GameScene.Slaying = false;
                    }

                    Network.Enqueue(new C.Attack {
                        Direction = Direction, Spell = Spell
                    });
                    GameManager.NextAction = Time.time + 2.5f;
                    break;

                case MirAction.Die:
                    Blocking = false;
                    if (HealthBar != null)
                    {
                        HealthBar.gameObject.SetActive(false);
                    }
                    break;

                case MirAction.Revive:
                    Blocking = true;
                    ActionFeed.Clear();
                    ActionFeed.Add(new QueuedAction {
                        Action = MirAction.Standing, Direction = action.Direction
                    });
                    //GameScene.pControl.TextureValid = false;
                    break;
                }
            }

            switch (CurrentAction)
            {
            case MirAction.Attack:
                PlayAnimation("Attack", -1, 0);
                break;

            case MirAction.Struck:
                SetAnimation("Struck", true);
                break;
            }
        }
        //GetComponentInChildren<Animator>()?.SetInteger("CurrentAction", (int)CurrentAction);
        SetAnimation("CurrentAction", (int)CurrentAction);
    }
Example #5
0
    public override void SetAction()
    {
        if (this == GameManager.User.Player && GameScene.QueuedAction != null)
        {
            ActionFeed.Clear();
            ActionFeed.Add(GameScene.QueuedAction);
            GameScene.QueuedAction = null;
        }

        if (ActionFeed.Count == 0)
        {
            CurrentAction = MirAction.Standing;
        }
        else
        {
            if (this == GameManager.User.Player && Time.time < GameManager.NextAction)
            {
                return;
            }

            QueuedAction action = ActionFeed[0];
            ActionFeed.RemoveAt(0);

            CurrentAction            = action.Action;
            Direction                = action.Direction;
            Model.transform.rotation = ClientFunctions.GetRotation(Direction);

            switch (CurrentAction)
            {
            case MirAction.Walking:
            case MirAction.Running:
                int steps = 1;
                if (CurrentAction == MirAction.Running)
                {
                    steps = 2;
                }

                Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position;
                TargetPosition = targetpos;

                if (this != GameManager.User.Player)
                {
                    Vector2 back = ClientFunctions.Back(action.Location, Direction, steps);
                    gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position;
                }

                GameManager.CurrentScene.Cells[(int)CurrentLocation.x, (int)CurrentLocation.y].RemoveObject(this);
                GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].AddObject(this);

                StartPosition  = gameObject.transform.position;
                TargetDistance = Vector3.Distance(transform.position, targetpos);
                IsMoving       = true;
                break;
            }

            CurrentLocation = action.Location;

            if (this == GameManager.User.Player)
            {
                switch (CurrentAction)
                {
                case MirAction.Standing:
                    Network.Enqueue(new C.Turn {
                        Direction = action.Direction
                    });
                    GameManager.NextAction  = Time.time + 2.5f;
                    GameManager.InputDelay  = Time.time + 0.5f;
                    GameManager.User.CanRun = false;
                    break;

                case MirAction.Walking:
                    Network.Enqueue(new C.Walk {
                        Direction = action.Direction
                    });
                    GameManager.NextAction       = Time.time + 2.5f;
                    GameManager.InputDelay       = Time.time + 0.5f;
                    GameManager.User.LastRunTime = Time.time;
                    GameManager.User.CanRun      = true;
                    break;

                case MirAction.Running:
                    Network.Enqueue(new C.Run {
                        Direction = action.Direction
                    });
                    GameManager.NextAction       = Time.time + 2.5f;
                    GameManager.InputDelay       = Time.time + 0.5f;
                    GameManager.User.LastRunTime = Time.time;
                    break;

                case MirAction.Attack:
                    Network.Enqueue(new C.Attack {
                        Direction = Direction, Spell = Spell.None
                    });
                    GameManager.NextAction = Time.time + 2.5f;
                    break;
                }
            }

            switch (CurrentAction)
            {
            case MirAction.Attack:
                GetComponentInChildren <Animator>().Play("Attack", -1, normalizedTime: 0f);
                break;
            }
        }
        GetComponentInChildren <Animator>()?.SetInteger("CurrentAction", (int)CurrentAction);
    }
Example #6
0
        public virtual void SetAction()
        {
            if (QueuedAction != null)
            {
                if ((ActionFeed.Count == 0) || (ActionFeed.Count == 1 && NextAction.Action == MirAction.Stance))
                {
                    ActionFeed.Clear();
                    ActionFeed.Add(QueuedAction);
                    QueuedAction = null;
                }
            }

            if (Observer == this && CMain.Time < MapControl.NextAction)// && CanSetAction)
            {
                //NextMagic = null;
                return;
            }

            if (ActionFeed.Count == 0)
            {
                CurrentAction = MirAction.Standing;

                Frames.Frames.TryGetValue(CurrentAction, out Frame);
                FrameIndex       = 0;
                EffectFrameIndex = 0;

                if (MapLocation != CurrentLocation)
                {
                    GameScene.Scene.MapControl.RemoveObject(this);
                    MapLocation = CurrentLocation;
                    GameScene.Scene.MapControl.AddObject(this);
                }

                if (Frame == null)
                {
                    return;
                }

                FrameInterval       = Frame.Interval;
                EffectFrameInterval = Frame.EffectInterval;

                SetLibraries();
            }
            else
            {
                QueuedAction action = ActionFeed[0];
                ActionFeed.RemoveAt(0);

                CurrentAction = action.Action;

                CurrentLocation = action.Location;
                MirDirection olddirection = Direction;
                Direction = action.Direction;

                Point temp;
                switch (CurrentAction)
                {
                case MirAction.ObserveMove:
                    var steps = 3;

                    temp = Functions.PointMove(CurrentLocation, Direction, -steps);

                    break;

                default:
                    temp = CurrentLocation;
                    break;
                }

                temp = new Point(action.Location.X, temp.Y > CurrentLocation.Y ? temp.Y : CurrentLocation.Y);

                if (MapLocation != temp)
                {
                    GameScene.Scene.MapControl.RemoveObject(this);
                    MapLocation = temp;
                    GameScene.Scene.MapControl.AddObject(this);
                }

                Frames.Frames.TryGetValue(CurrentAction, out Frame);

                SetLibraries();

                FrameIndex       = 0;
                EffectFrameIndex = 0;

                if (Frame == null)
                {
                    return;
                }

                FrameInterval       = Frame.Interval;
                EffectFrameInterval = Frame.EffectInterval;

                if (this == Observer)
                {
                    switch (CurrentAction)
                    {
                    case MirAction.ObserveMove:
                        Network.Enqueue(new C.ObserveMove {
                            Direction = Direction
                        });
                        GameScene.Scene.MapControl.FloorValid = false;
                        MapControl.NextAction = CMain.Time + 1000;
                        break;
                    }
                }


                switch (CurrentAction)
                {
                case MirAction.ObserveMove:
                    GameScene.Scene.Redraw();
                    break;
                }
            }

            GameScene.Scene.MapControl.TextureValid = false;

            NextMotion  = CMain.Time + FrameInterval;
            NextMotion2 = CMain.Time + EffectFrameInterval;
        }
Example #7
0
    public override void SetAction()
    {
        if (ActionFeed.Count == 0)
        {
            if (Dead)
            {
                CurrentAction = MirAction.Dead;
            }
            else
            {
                CurrentAction = MirAction.Standing;
            }
        }
        else
        {
            QueuedAction action = ActionFeed[0];
            ActionFeed.RemoveAt(0);

            CurrentAction            = action.Action;
            Direction                = action.Direction;
            Model.transform.rotation = ClientFunctions.GetRotation(Direction);
            BossHealupdate();
            switch (CurrentAction)
            {
            case MirAction.Walking:
            case MirAction.Running:
                int steps = 1;
                if (CurrentAction == MirAction.Running)
                {
                    steps = 2;
                }

                Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position;
                TargetPosition = targetpos;

                Vector2 back = ClientFunctions.Back(action.Location, Direction, steps);
                gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position;

                GameManager.CurrentScene.Cells[CurrentLocation.x, CurrentLocation.y].RemoveObject(this);
                GameManager.CurrentScene.Cells[action.Location.x, action.Location.y].AddObject(this);

                StartPosition  = gameObject.transform.position;
                TargetDistance = Vector3.Distance(transform.position, targetpos);
                IsMoving       = true;
                break;

            case MirAction.Attack:
                soundPlayer.ExecuteSound(AttackSound, gameObject, "Player");
                soundPlayer.Play();
                break;

            case MirAction.Struck:
                break;

            case MirAction.Die:
                soundPlayer.ExecuteSound(DeathSound, gameObject, "Player");
                soundPlayer.Play();
                Blocking = false;
                if (HealthBar != null)
                {
                    HealthBar.gameObject.SetActive(false);
                }
                CheckBossDead();
                Dead = true;
                break;
            }

            CurrentLocation = action.Location;
        }

        GetComponentInChildren <Animator>().SetInteger("CurrentAction", (int)CurrentAction);
    }