Exemplo n.º 1
0
 public void Enter()
 {
     Debug.Log("Entered Move Phase");
     selectedMoveRef = (SelectedMove)AssetDatabase.LoadAssetAtPath("Assets/Scripts/Utility/Test/SelectedMove.asset", typeof(SelectedMove));
     selectedMoveRef.ClearMove();
     // xml = XmlReader.Create(@"C:\Users\Martin\Documents\GitHub\SummerProject\SummerProject\Assets\Scripts\MoveData\MoveData.xml");
 }
Exemplo n.º 2
0
        void GetControllerInfos()
        {
            if (controller == null)
            {
                GetController();
                return;
            }

            selectedMove = controller.selectedMove;
            hoverEntity  = controller.hoverEntity;
        }
Exemplo n.º 3
0
        private void EndAttackState()
        {
            if (selectedMove != null)
            {
                canMove   = nav.updatePosition = true;
                canRotate = nav.updateRotation = true;
                nav.SetDestination(savedDestination);
            }

            anim.SetBool("PhysicalAttack", false);
            anim.SetBool("SpecialAttack", false);

            selectedMove = null;
        }
Exemplo n.º 4
0
        private void SelectMove(int index)
        {
            /*if(Network.isServer)
             *      networkView.RPC("SelectMove", RPCMode.Others, index);*/

            selectedMove = new SelectedMove(moveSet[index]);

            bool isSelfOnly = ((int)PokemonRelation.Self ^ (int)selectedMove.info.AllowedTargets) == 0;

            if (isSelfOnly)
            {
                GetComponent <NetworkView>().RPC("ValidateControl", RPCMode.Server, (int)InputType.LeftClick, transform.position + transform.forward, gameObject.GetComponent <NetworkView>().viewID, index);
            }
        }
Exemplo n.º 5
0
 public GamePlayerMoveResult MakeMove(PieceColour pieceColour, GameState gameState)
 {
     CurrentTurn = true;
     GamePlayerMoveResult gamePlayerMoveResult;
     // check if human has lost
     if (gameState.CalculateAvailableMoves(pieceColour).Count > 0)
     {
         if (null == SelectedMove)
         {
             throw new ArgumentException("SelectedMove is null.");
         }
         gamePlayerMoveResult = new GamePlayerMoveResult(SelectedMove.PerformMove(), MoveStatus.SuccessfulMove);
     }
     else
     {
         gamePlayerMoveResult = new GamePlayerMoveResult(gameState, MoveStatus.NoLegalMoves);
     }
     SelectedMove = null;
     CurrentTurn = false;
     return gamePlayerMoveResult;
 }
Exemplo n.º 6
0
        public GamePlayerMoveResult MakeMove(PieceColour pieceColour, GameState gameState)
        {
            CurrentTurn = true;
            GamePlayerMoveResult gamePlayerMoveResult;

            // check if human has lost
            if (gameState.CalculateAvailableMoves(pieceColour).Count > 0)
            {
                while (null == SelectedMove)
                {
                    Thread.Sleep(10);
                }
                gamePlayerMoveResult = new GamePlayerMoveResult(SelectedMove.PerformMove(), MoveStatus.SuccessfulMove);
            }
            else
            {
                gamePlayerMoveResult = new GamePlayerMoveResult(gameState, MoveStatus.NoLegalMoves);
            }
            SelectedMove = null;
            CurrentTurn  = false;
            return(gamePlayerMoveResult);
        }
Exemplo n.º 7
0
        internal void Move()
        {
            if (SelectZmove)
            {
                Pokemon.Zmove = true;
            }
            STs.FocusPunch(Controller);
            LastMoveTurn = Controller.TurnNumber;
            STs.WillAct(this);
            switch (Action)
            {
            case PokemonAction.Stiff:
                PTs.ShowLogPm(this, "Stiff");
                Action = PokemonAction.Done;
                break;

            case PokemonAction.Moving:
                if (AtkContext.Move.Id == Ms.SKY_DROP)
                {
                    CoordY = CoordY.Plate;
                    if (AtkContext.Target.Defender.AliveOnboard)
                    {
                        AtkContext.Target.Defender.CoordY = CoordY.Plate;
                        AtkContext.Target.Defender.OnboardPokemon.RemoveCondition(Cs.SkyDrop);
                    }
                    else
                    {
                        AtkContext.SetTargets(Enumerable.Empty <DefContext>());
                    }
                }
                if (CanExecute())
                {
                    if (AtkContext.Move.Id != Ms.BIDE)
                    {
                        PTs.ShowLogPm(this, "UseMove", AtkContext.Move.Id);
                    }
                    AtkContext.ContinueExecute(SelectedTarget);
                }
                else
                {
                    Action = PokemonAction.Done;
                }
                break;

            case PokemonAction.MoveAttached:
            {
                var o = OnboardPokemon.GetCondition(Cs.Encore);
                if (o != null)
                {
                    foreach (var m in Moves)
                    {
                        if (m.MoveE == o.Move)
                        {
                            SelectedMove = m;
                        }
                    }
                }
            }
                ATs.StanceChange(this);
                if (SelectZmove && SelectedMove.MoveE.Move.Category == MoveCategory.Status)
                {
                    switch (GameHelper.ZStatus(SelectedMove.MoveE.Move.Id))
                    {
                    case 0:
                        break;

                    case 1:
                        this.ChangeLv7D(this, StatType.Atk, 1, false);
                        break;

                    case 2:
                        this.ChangeLv7D(this, StatType.Atk, 2, false);
                        break;

                    case 3:
                        this.ChangeLv7D(this, StatType.Atk, 3, false);
                        break;

                    case 4:
                        this.ChangeLv7D(this, StatType.Def, 1, false);
                        break;

                    case 5:
                        this.ChangeLv7D(this, StatType.SpAtk, 1, false);
                        break;

                    case 6:
                        this.ChangeLv7D(this, StatType.SpAtk, 2, false);
                        break;

                    case 7:
                        this.ChangeLv7D(this, StatType.SpDef, 1, false);
                        break;

                    case 8:
                        this.ChangeLv7D(this, StatType.SpDef, 2, false);
                        break;

                    case 9:
                        this.ChangeLv7D(this, StatType.Speed, 1, false);
                        break;

                    case 10:
                        this.ChangeLv7D(this, StatType.Speed, 2, false);
                        break;

                    case 11:
                        this.ChangeLv7D(this, StatType.Accuracy, 1, false);
                        break;

                    case 12:
                        this.ChangeLv7D(this, StatType.Evasion, 1, false);
                        break;

                    case 13:
                        this.ChangeLv7D(this, false, false, 1, 1, 1, 1, 1, 0, 0);
                        break;

                    case 14:
                        if (OnboardPokemon.AddCondition(Cs.FocusEnergy))
                        {
                            this.ShowLogPm("En" + Cs.FocusEnergy);
                        }
                        break;

                    case 15:
                        ITs.Reset7D(this);
                        break;

                    case 16:
                        this.HpRecover(Pokemon.MaxHp);
                        break;

                    case 17:
                        if (Pokemon.Owner.PmsAlive > Controller.GameSettings.Mode.OnboardPokemonsPerPlayer())
                        {
                            Tile.SetTurnCondition(Cs.Zheal);
                        }
                        break;

                    case 18:
                        OnboardPokemon.AddTurnCondition(Cs.FollowMe, SelectedMove.MoveE.Move.Id);
                        this.ShowLogPm(Ls.EnFollowMe);
                        break;

                    default:
                        break;
                    }
                    if (SelectedMove.MoveE.Move.Id == Ms.CURSE)
                    {
                        if (OnboardPokemon.HasType(BattleType.Ghost))
                        {
                            this.HpRecover(Pokemon.MaxHp);
                        }
                        else
                        {
                            this.ChangeLv7D(this, StatType.Atk, 1, false);
                        }
                    }
                }
                if (CanExecute() && SelectedMove.CanExecute())
                {
                    _atkContext = null;
                    SelectedMove.Execute();
                    var o = OnboardPokemon.GetCondition(Cs.LastMove);
                    if (o == null)
                    {
                        o      = new Condition();
                        o.Move = AtkContext.Move;
                        OnboardPokemon.SetCondition(Cs.LastMove, o);
                    }
                    else if (o.Move != AtkContext.Move)
                    {
                        o.Move = AtkContext.Move;
                        o.Int  = 0;
                    }
                    if (AtkContext.Fail)
                    {
                        o.Int = 0;
                    }
                    else
                    {
                        o.Int++;
                    }
                    Controller.Board.SetCondition(Cs.LastMove, o);
                }
                else
                {
                    OnboardPokemon.RemoveCondition(Cs.LastMove);
                    Action = PokemonAction.Done;
                }
                if (AtkContext != null && AtkContext.Move.Dance && AtkContext.Attacker.LastMoveTurn == Controller.TurnNumber)
                {
                    foreach (var p in Controller.Board.Pokemons)
                    {
                        if (p != null && p.AbilityE(As.Dancer) && p != AtkContext.Attacker)
                        {
                            p.RaiseAbility();
                            AtkContext dance = new AtkContext(p);
                            dance.StartExecute(AtkContext.Move, null, "UseMove", false);
                        }
                    }
                }
                break;
            } //switch(Action)
        }
Exemplo n.º 8
0
        public void Start()
        {
            entityManager = GetComponent <EntityManager>();

            if (int.TryParse(name.Split('-') [0], out pokedex_id))
            {
                Debug.LogError("The GameObject's name doesn't contain the Pokedex ID");
            }

            for (int statID = 0; statID < (int)StatsList.COUNT; statID++)            // Assignment of the base stats.
            {
                entityManager.stats.baseStats[statID] = Pokedex.pokemons[pokedex_id].Statistics.baseStats[statID];
            }

            entityManager.stats.levelingRate = Pokedex.pokemons[pokedex_id].LevelingSpeed;

            anim = GetComponent <Animator>();
            nav  = GetComponent <NavMeshAgent>();

            marker = null;

            nav.autoRepath     = true;
            nav.updateRotation = false;          // We manage the rotation ourselves.
            nav.autoBraking    = false;          // This is less fancy, but more "accurate" for the player.

            laserSource = transform.Find("Armature/" + laserSourcePath);

            hoverEntity = null;

            int i = pokedex_id % 3;

            switch (i)
            {
            case 0:
                moveSet.Add("Surf");
                moveSet.Add("Bubble");
                moveSet.Add("Waterfall");
                moveSet.Add("Icicle Crash");
                break;

            case 1:
                moveSet.Add("Flamethrower");
                moveSet.Add("Poison Gas");
                moveSet.Add("Poison Sting");
                moveSet.Add("Venoshock");
                break;

            case 2:
                moveSet.Add("Gust");
                moveSet.Add("Hurricane");
                moveSet.Add("Thunder Shock");
                moveSet.Add("Razor Leaf");
                break;
            }

            selectedMove = null;

            /*currentHP = maxHP;
             * savedDestination = new Vector3();*/

            this.gameObject.transform.parent = SceneHelper.GetContainer(Container.Pokemons).transform;

            Celshading.instance.ApplyShadingMode();
            ShareFogVision(); // This shouldn't be within this script.
        }
Exemplo n.º 9
0
        private void ValidateControl(int input, Vector3 pos, NetworkViewID viewID, int moveIndex)
        {
            if (Network.isServer)
            {
                MatchManager matchManager = GameObject.Find("GameManager").GetComponent <MatchManager>();

                if (matchManager._state == Mobamon.GameManager.Enums.MatchState.Running)
                {
                    if (input == (int)InputType.LeftClick)
                    {
                        if (selectedMove == null && moveIndex == -1)
                        {
                            // The character has to move at least half of its width.
                            //if((theChosenHit.point - transform.position).magnitude >= nav.radius)
                            {
                                SetDestination(pos);
                            }
                        }
                        else
                        {
                            // If a move is selected, but not launched :
                            //if(!selectedMove.IsLaunched())
                            if (selectedMove == null && moveIndex != -1)
                            {
                                SelectMove(moveIndex);

                                GameObject      targetPokemon = new GameObject();
                                PokemonRelation relation      = PokemonRelation.ERROR;

                                if (viewID != NetworkViewID.unassigned)
                                {
                                    targetPokemon = NetworkView.Find(viewID).gameObject;
                                    relation      = entityManager.GetRelation(targetPokemon);
                                }

                                MoveTargetKind targetKind     = selectedMove.info.TargetKind;
                                bool           attackLaunched = false;

                                if (targetKind == MoveTargetKind.Area)
                                {
                                    SetAttackState(NetworkViewID.unassigned, pos);
                                    attackLaunched = true;
                                }
                                else if (targetKind == MoveTargetKind.Single && relation != PokemonRelation.ERROR)   // If the target type is not an area, then it's a single target spell. Therefore he needs a target.
                                {
                                    bool isSelfOnly = ((int)PokemonRelation.Self ^ (int)selectedMove.info.AllowedTargets) == 0;

                                    if (isSelfOnly)
                                    {
                                        SetAttackState(viewID, pos);
                                        attackLaunched = true;
                                    }
                                    else
                                    {
                                        if (((int)selectedMove.info.AllowedTargets & (int)relation) != 0)
                                        {
                                            SphereCollider targetCollider = (SphereCollider)targetPokemon.GetComponent <Collider>();

                                            if (Vector3.Magnitude(targetPokemon.transform.position - transform.position) <= selectedMove.info.Range / 100f + nav.radius + targetCollider.radius)
                                            {
                                                SetAttackState(viewID, pos);
                                                attackLaunched = true;
                                            }
                                        }
                                    }
                                }

                                if (!attackLaunched)
                                {
                                    // If the player failed to click a right target for his attack, then we unselect it.
                                    selectedMove = null;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        public void Controls()
        {
            if (isMine)
            {
                // Uses : selectedMove, hit and hoverEntity

                if (!(selectedMove != null && selectedMove.IsLaunched()))
                {
                    if ((Input.GetKeyDown("q") || Input.GetKeyDown("a")) && moveSet[0] != null)
                    {
                        SelectMove(0);
                    }
                    else if ((Input.GetKeyDown("w") || Input.GetKeyDown("z")) && moveSet[1] != null)
                    {
                        SelectMove(1);
                    }
                    else if (Input.GetKeyDown("e") && moveSet[2] != null)
                    {
                        SelectMove(2);
                    }
                    else if (Input.GetKeyDown("r") && moveSet[3] != null)
                    {
                        SelectMove(3);
                    }
                }

                if (selectedMove != null && !selectedMove.IsLaunched())
                {
                    Ray ray = myCam.ScreenPointToRay(Input.mousePosition);

                    if (Physics.Raycast(ray, out hit) && hit.transform.root.gameObject == SceneHelper.GetContainer(Container.Entities))
                    {
                        hoverEntity = hit.transform.gameObject;

                        SphereCollider targetCollider = (SphereCollider)hoverEntity.GetComponent <Collider>();

                        if (selectedMove.info.TargetKind == MoveTargetKind.Single &&
                            Vector3.Magnitude(hoverEntity.transform.position - transform.position) > selectedMove.info.Range / 100f + nav.radius + targetCollider.radius)
                        {
                            hoverEntity = null;
                        }
                    }
                    else
                    {
                        hoverEntity = null;
                    }
                }

                if (Input.GetMouseButtonDown(0))
                {
                    if (selectedMove == null)
                    {
                        Ray          ray = myCam.ScreenPointToRay(Input.mousePosition);
                        RaycastHit[] hits;
                        hits = Physics.RaycastAll(ray, 100.0f);

                        RaycastHit theChosenHit = new RaycastHit();
                        foreach (RaycastHit singleHit in hits)
                        {
                            if (singleHit.collider.transform.parent.name == "Terrain")
                            {
                                if (theChosenHit.Equals(new RaycastHit()) || singleHit.distance < theChosenHit.distance)
                                {
                                    theChosenHit = singleHit;
                                }
                            }
                        }

                        if (!theChosenHit.Equals(new RaycastHit()))
                        {
                            // The character has to move at least half of its width.
                            //if((theChosenHit.point - transform.position).magnitude >= nav.radius)
                            {
                                theChosenHit.point.Set(theChosenHit.point.x, 0, theChosenHit.point.z);
                                GetComponent <NetworkView>().RPC("ValidateControl", RPCMode.Server, (int)InputType.LeftClick, theChosenHit.point, NetworkViewID.unassigned, -1);
                            }
                        }
                    }
                    else
                    {
                        // If a move is selected, but not launched :
                        if (!selectedMove.IsLaunched())
                        {
                            bool attackLaunched = false;

                            MoveTargetKind targetKind = selectedMove.info.TargetKind;

                            int moveIndex = -1;
                            for (int i = 0; i < moveSet.Count; i++)
                            {
                                if (selectedMove.name == moveSet[i])
                                {
                                    moveIndex = i;
                                }
                            }

                            if (targetKind == MoveTargetKind.Area)
                            {
                                GetComponent <NetworkView>().RPC("ValidateControl", RPCMode.Server, (int)InputType.LeftClick, hit.point, NetworkViewID.unassigned, moveIndex);
                                attackLaunched = true;
                            }
                            else if (targetKind == MoveTargetKind.Single && hoverEntity != null)                            // If the target type is not an area, then it's a single target spell. Therefore he needs a target.
                            {
                                PokemonRelation relation = entityManager.GetRelation(hoverEntity);

                                if ((relation & selectedMove.info.AllowedTargets) != 0)
                                {
                                    SphereCollider targetCollider = (SphereCollider)hoverEntity.GetComponent <Collider>();

                                    if (Vector3.Magnitude(hoverEntity.transform.position - transform.position) <= selectedMove.info.Range / 100f + nav.radius + targetCollider.radius)
                                    {
                                        GetComponent <NetworkView>().RPC("ValidateControl", RPCMode.Server, (int)InputType.LeftClick, hit.point, hoverEntity.GetComponent <NetworkView>().viewID, moveIndex);
                                        attackLaunched = true;
                                    }
                                }
                            }

                            if (!attackLaunched)
                            {
                                selectedMove = null;                                 // If the player failed to click a right target for his attack, then we unselect it.
                            }

                            hoverEntity = null;
                        }
                    }
                }
                else if (Input.GetMouseButtonDown(1))
                {
                    //SetLife(currentHP - 2f);

                    if (selectedMove != null && !selectedMove.IsLaunched())
                    {
                        selectedMove = null;
                    }
                }
            }
        }
Exemplo n.º 11
0
        internal void Move()
        {
            STs.FocusPunch(Controller);
            LastMoveTurn = Controller.TurnNumber;
            STs.WillAct(this);
            switch (Action)
            {
            case PokemonAction.Stiff:
                PTs.ShowLogPm(this, "Stiff");
                Action = PokemonAction.Done;
                break;

            case PokemonAction.Moving:
                if (AtkContext.Move.Id == Ms.SKY_DROP)
                {
                    CoordY = CoordY.Plate;
                    if (AtkContext.Target.Defender.AliveOnboard)
                    {
                        AtkContext.Target.Defender.CoordY = CoordY.Plate;
                        AtkContext.Target.Defender.OnboardPokemon.RemoveCondition(Cs.SkyDrop);
                    }
                    else
                    {
                        AtkContext.SetTargets(Enumerable.Empty <DefContext>());
                    }
                }
                if (CanExecute())
                {
                    if (AtkContext.Move.Id != Ms.BIDE)
                    {
                        PTs.ShowLogPm(this, "UseMove", AtkContext.Move.Id);
                    }
                    AtkContext.ContinueExecute(SelectedTarget);
                }
                else
                {
                    Action = PokemonAction.Done;
                }
                break;

            case PokemonAction.MoveAttached:
            {
                var o = OnboardPokemon.GetCondition(Cs.Encore);
                if (o != null)
                {
                    foreach (var m in Moves)
                    {
                        if (m.MoveE == o.Move)
                        {
                            SelectedMove = m;
                        }
                    }
                }
            }
                ATs.StanceChange(this);
                if (CanExecute() && SelectedMove.CanExecute())
                {
                    _atkContext = null;
                    SelectedMove.Execute();
                    var o = OnboardPokemon.GetCondition(Cs.LastMove);
                    if (o == null)
                    {
                        o      = new Condition();
                        o.Move = AtkContext.Move;
                        OnboardPokemon.SetCondition(Cs.LastMove, o);
                    }
                    else if (o.Move != AtkContext.Move)
                    {
                        o.Move = AtkContext.Move;
                        o.Int  = 0;
                    }
                    if (AtkContext.Fail)
                    {
                        o.Int = 0;
                    }
                    else
                    {
                        o.Int++;
                    }
                    Controller.Board.SetCondition(Cs.LastMove, o);
                }
                else
                {
                    OnboardPokemon.RemoveCondition(Cs.LastMove);
                    Action = PokemonAction.Done;
                }
                break;
            } //switch(Action)
        }