protected void MoveTo(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.Document != null;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         MoveTarget target = MoveTarget.None;
         if (args.Parameter is MoveTarget)
         {
             target = (MoveTarget)args.Parameter;
         }
         else if (args.Parameter is string)
         {
             try
             {
                 target = (MoveTarget)Enum.Parse(
                     typeof(MoveTarget),
                     (string)args.Parameter,
                     true);
             }
             catch
             {
             }
         }
         if (target != MoveTarget.None)
         {
             args.Document.Content.AutoClearSelection = true;
             args.Document.Content.MoveTo(target);
         }
     }
 }
Esempio n. 2
0
    IEnumerator RuneMoveEffects(MoveEffects effects, Pokemon source, Pokemon target, MoveTarget moveTarget) //Creating a function of the Effects move, so we'll call it easyly
    {
        if (effects.Boosts != null)                                                                         //Call for stat boost
        {
            if (moveTarget == MoveTarget.Self)
            {
                source.ApplyBoosts(effects.Boosts);
            }
            else
            {
                target.ApplyBoosts(effects.Boosts);
            }
        }

        //Check from the dictionnary if there are any status condition, and call for status
        if (effects.Status != ConditionID.none)
        {
            target.SetStatus(effects.Status);
        }
        //Same with volatile status
        if (effects.VolatileStatus != ConditionID.none)
        {
            target.SetVolatileStatus(effects.VolatileStatus);
        }

        yield return(ShowStatusChanges(source));

        yield return(ShowStatusChanges(target));
    }
Esempio n. 3
0
        private IEnumerator UseMoveEffects(MoveEffects effects, MonsterObj attackingMonster, MonsterObj defendingMonster,
                                           MoveTarget moveTarget)
        {
            // Handle any stat changes.
            if (effects.StatChanges != null)
            {
                if (moveTarget == MoveTarget.Self)
                {
                    attackingMonster.ApplyStatChanges(effects.StatChanges);
                }
                else
                {
                    defendingMonster.ApplyStatChanges(effects.StatChanges);
                }
            }

            // Handle any status conditions.
            if (effects.Status != ConditionID.None)
            {
                defendingMonster.SetStatus(effects.Status);
            }

            // Handle any volatile status conditions.
            if (effects.VolatileStatus != ConditionID.None)
            {
                defendingMonster.SetVolatileStatus(effects.VolatileStatus);
            }

            yield return(ShowStatusChanges(attackingMonster));

            yield return(ShowStatusChanges(defendingMonster));
        }
Esempio n. 4
0
    IEnumerator RunMoveEffects(MoveEffects effects, Animal source, Animal target, MoveTarget moveTarget)
    {
        // Stat Boosting
        if (effects.Boosts != null)
        {
            if (moveTarget == MoveTarget.Self)
            {
                source.ApplyBoosts(effects.Boosts);
            }
            else
            {
                target.ApplyBoosts(effects.Boosts);
            }
        }

        //Status Conditions
        if (effects.Status != ConditionID.none)
        {
            target.SetStatus(effects.Status);
        }

        //VolatileStatus Conditions
        if (effects.VolatileStatus != ConditionID.none)
        {
            target.SetVolatileStatus(effects.VolatileStatus);
        }

        yield return(ShowStatusChanges(source));

        yield return(ShowStatusChanges(target));
    }
Esempio n. 5
0
        private void LaunchAttack(float holdDuration)
        {
            if (selectedMove != null && selectedMove.target != null)            //networkView.isMine &&
            {
                GameObject move = (GameObject)Instantiate(Resources.Load("Moves/" + selectedMove.name));
                move.transform.parent = GameObject.Find("Moves").transform;

                MoveTarget source = new MoveTarget(gameObject, transform.position);

                DamageManager damageManagerScript = (DamageManager)move.AddComponent(typeof(DamageManager));
                damageManagerScript.SetParameters(selectedMove.name, source, selectedMove.target);

                Move  moveScript     = (Move)move.AddComponent(typeof(Move));
                float freezeDuration = moveScript.SetMoveParameters(selectedMove.name, source, selectedMove.target);
                //float freezeDuration = selectedMove.info.Duration;

                Invoke("Unfreeze", freezeDuration);                 // Even the non-immobilizing moves need to "unfreeze" the animation.

                if (freezeDuration > 0)
                {
                    float maxAttackAnimSpeed = 0.2f;

                    /*if(attackAnimHalfDuration.ContainsKey(selectedMove.info.attackCategory))
                     * {
                     *      float ratio = attackAnimHalfDuration[selectedMove.info.attackCategory] / freezeDuration / 2;
                     *      anim.speed = Mathf.Min(ratio, maxAttackAnimSpeed);
                     * }
                     * else*/
                    {
                        anim.speed = maxAttackAnimSpeed;
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Stores the caster and the target of the move.
        /// This method has to be called directly upon creation of this DamageManager component.
        /// </summary>
        /// <param name="_moveName">Move's name.</param>
        /// <param name="_caster">Caster's MoveTarget.</param>
        /// <param name="_target">Target's MoveTarget.</param>
        public void SetParameters(string _moveName, MoveTarget _caster, MoveTarget _target)
        {
            if (!Attackdex.move.ContainsKey(_moveName))
            {
                Debug.LogError("The move '" + _moveName + "' is not registered in the Attackdex.");
            }
            else
            {
                moveName = _moveName;
                moveInfo = Attackdex.move[moveName];
                if (moveInfo.TargetKind == MoveTargetKind.Single)
                {
                    timeBeforeDamage = moveInfo.DelayBeforeDamage;
                }
            }

            caster = _caster;
            target = _target;

            if (moveInfo.TargetKind != MoveTargetKind.Single) // We assume that those spells can't deal damage to several targets.
            {
                foreach (ParticleSystem ps in this.GetComponentsInChildren <ParticleSystem>())
                {
                    if (ps.name == "MainParticle")
                    {
                        TransmitCollisionMessage script = ps.gameObject.AddComponent <TransmitCollisionMessage>();
                        script.SetManager(this.GetComponent <DamageManager>());
                    }
                }
            }
        }
Esempio n. 7
0
    public void NewPos(int side)
    {
        float GX = (float)Random.Range(-2, 2);

        if (moveTo != null)
        {
            if (GX > moveTo.X)
            {
                xForce *= 1.5f;
            }
            else if (GX < moveTo.X)
            {
                xForce /= 1.5f;
            }
        }
        moveTo = new MoveTarget(GX, transform.position.x);
        if (side == 1)
        {
            GX     = (float)Random.Range(-2, 0);
            moveTo = new MoveTarget(GX, transform.position.x);
        }
        else if (side == 2)
        {
            GX     = (float)Random.Range(0, 2);
            moveTo = new MoveTarget(GX, transform.position.x);
        }
    }
Esempio n. 8
0
    IEnumerator RunMoveEffects(MoveEffects Effects, Pokemon source, Pokemon target, MoveTarget moveTarget)
    {
        var effects = Effects;

        if (effects.Boosts != null)
        {
            if (moveTarget == MoveTarget.Self)
            {
                source.ApplyBoosts(effects.Boosts);
            }
            else
            {
                target.ApplyBoosts(effects.Boosts);
            }
        }

        if (effects.Status != StatusID.none)
        {
            target.SetStatus(effects.Status);
        }

        if (effects.VolatileStatus != StatusID.none)
        {
            target.SetVolatileStatus(effects.VolatileStatus);
        }
        yield return(ShowStatChanges(source));

        yield return(ShowStatChanges(target));
    }
Esempio n. 9
0
 public SlideTransition(float time, FourWayDirection direction, MoveTarget moveTarget, SlideTransitionInterpolator interpolator)
 {
     this.Time          = time;
     this.MoveDirection = direction;
     this.MoveTarget    = moveTarget;
     this.Interpolator  = interpolator;
 }
Esempio n. 10
0
        public SelectedMove(string _name)
        {
            name = _name;

            target = null;
            info   = Attackdex.move[name];
            isDone = false;
        }
Esempio n. 11
0
 protected override void Decode()
 {
     PlayerID = _incoming.ReadInt32();
     id = _incoming.ReadInt32();
     Quantity = _incoming.ReadInt32();
     Slot = _incoming.ReadInt32();
     To = (MoveTarget)_incoming.ReadByte();
     From = (MoveTarget)_incoming.ReadByte();
 }
Esempio n. 12
0
        /// <summary>
        /// Sets the move parameters.
        /// </summary>
        /// <param name="moveName">Move name.</param>
        /// <param name="source">Source.</param>
        /// <param name="target">Target.</param>
        public float SetMoveParameters(string moveName, MoveTarget source, MoveTarget target)
        {
            float animationFreezeDuration = 0f;

            if (!Attackdex.move.ContainsKey(moveName))
            {
                Debug.LogError("The move '" + moveName + "' is not registered in Attackdex");
            }
            else
            {
                this.Info      = Attackdex.move[moveName];
                this.IsRunning = true;
                this.Source    = source;
                this.Target    = target;

                // Positions the Attack gameobject
                this.transform.position = this.GetPosition();
                this.transform.forward  = source.GameObject.transform.forward;

                // Starts the FX
                this.ParticleSystems = this.GetComponentsInChildren <ParticleSystem>().ToList();
                //this.PlayFX();

                // Retrieves the MainParticle
                Transform mainParticleTransform = transform.Find("MainParticle");

                if (mainParticleTransform == null)
                {
                    Debug.LogError("The move " + moveName + " has no MainParticle child.");
                }
                else
                {
                    this.MainParticleSystem = (ParticleSystem)mainParticleTransform.gameObject.GetComponent(typeof(ParticleSystem));

                    if (this.MainParticleSystem == null)
                    {
                        Debug.LogError("The MainParticle of the move " + moveName + " contains no ParticleSystem component.");
                    }
                    else
                    {
                        // If the move should not stop the attack animation, then we don't want to freeze it and we return 0.
                        if (this.Info.IsImmobilizingCaster)
                        {
                            animationFreezeDuration = this.MainParticleSystem.duration;

                            if (animationFreezeDuration > 2)
                            {
                                Debug.LogError("The MainParticle of " + moveName + " lasts way too long and may cause animation issues.");
                            }
                        }
                    }
                }
            }

            return(animationFreezeDuration);
        }
Esempio n. 13
0
    void SetState(State newState, float initialWaitedTime = 0.0f)
    {
        waitedTime = initialWaitedTime;

        // Stop cancelling special.
        cancelSpecial = false;

        // Disable input if not idle.
        if (state == State.Idle && newState != State.Idle)
        {
            // store the old value (only the Idle state contains the "real" value)
            inputEnabledCached = inputEnabled;
        }
        if (newState != State.Idle)
        {
            inputEnabled = false;
        }
        else
        {
            // restore the old value
            inputEnabled = inputEnabledCached;
        }

        state = newState;

        switch (state)
        {
        case State.Moving:
        {
            currentMove = moves[0];
            break;
        }

        case State.CompletingMove:
        {
            // Set speed and move delta.
            speed     = 0.0f;
            moveDelta = new Vector3(0.0f, moveDelta.y, 0.0f);

            break;
        }

        case State.Idle:
        case State.CompletingTurn:
        case State.CompletingFollow:
        {
            // Set speed, move delta and rotation speed.
            speed       = 0.0f;
            moveDelta   = new Vector3(0.0f, moveDelta.y, 0.0f);
            rotateSpeed = 0.0f;

            break;
        }
        }
    }
    public void StartUpActions()
    {
        this.hideCoroutine = StartCoroutine(HideAfterTime(timeToHide));
        // this.audioController.Play();
        MoveTarget moveTarget = GetComponent <MoveTarget>();

        if (moveTarget != null)
        {
            moveTarget.enabled = true;
        }
    }
Esempio n. 15
0
        public async Task GetMoveTargetResourceAsyncIntegrationTest()
        {
            // assemble
            PokeApiClient client = new PokeApiClient();

            // act
            MoveTarget moveTarget = await client.GetResourceAsync <MoveTarget>(1);

            // assert
            Assert.True(moveTarget.Id != default(int));
        }
Esempio n. 16
0
 private void RaiseOrLower()
 {
     if (Input.GetKey(KeyCode.Q))
     {
         MoveTarget.Translate(Vector3.down * speed * Time.deltaTime, Space.World);
     }
     else if (Input.GetKey(KeyCode.E))
     {
         MoveTarget.Translate(Vector3.up * speed * Time.deltaTime, Space.World);
     }
 }
Esempio n. 17
0
 public Move(string name, PokemonType type, int?power, DamageType?damageType, int accuracy, MoveTarget target, int basePP, int maxPossiblePP, int priority, int criticalHitStage)
 {
     Name             = name;
     Type             = type;
     Power            = power;
     DamageType       = damageType;
     Accuracy         = accuracy;
     Target           = target;
     BasePP           = basePP;
     MaxPPLimit       = maxPossiblePP;
     Priority         = priority;
     CriticalHitStage = criticalHitStage;
 }
Esempio n. 18
0
    void SetState(State newState, float initialWaitedTime = 0.0f)
    {
        waitedTime = initialWaitedTime;
        state      = newState;

        // Stop cancelling special.
        cancelSpecial = false;

        // Disable input if not idle.
        if (state != State.Idle)
        {
            Debug.Log(state);
            inputEnabled = false;
        }
        else
        {
            inputEnabled = true;
        }

        switch (state)
        {
        case State.Moving:
        {
            currentMove = moves[0];
            break;
        }

        case State.CompletingMove:
        {
            // Set speed and move delta.
            speed     = 0.0f;
            moveDelta = new Vector3(0.0f, moveDelta.y, 0.0f);

            break;
        }

        case State.Idle:
        case State.CompletingTurn:
        case State.CompletingFollow:
        {
            // Set speed, move delta and rotation speed.
            speed       = 0.0f;
            moveDelta   = new Vector3(0.0f, moveDelta.y, 0.0f);
            rotateSpeed = 0.0f;

            break;
        }
        }
    }
Esempio n. 19
0
        private void MoveDestination(MoveTarget moveTarget, ActorAI actor)
        {
            float   pas         = this.currentSpeedLevel * RandomSpeedFactor * Time.deltaTime;
            Vector3 destination = Vector3.zero;

            switch (moveTarget)
            {
            case MoveTarget.Item:
                destination = ItemTargetDestination;
                break;

            case MoveTarget.Map:
                destination = MapDestination;
                break;

            case MoveTarget.Opponent:
                destination = OpponentTargetDestination;
                break;

            default:
                break;
            }

            destination.y = FloorYOffset;

            NavMeshPath path = new NavMeshPath();

            NavMesh.CalculatePath(actor.transform.position, destination, NavMesh.AllAreas, path);
            Vector3[] pathpoints;
            if (path.status == NavMeshPathStatus.PathComplete)
            {
                pathpoints = new Vector3[path.corners.Length];
                int nbr = path.GetCornersNonAlloc(pathpoints);
                if (nbr > PathVectorIndex)
                {
                    destination = pathpoints[PathVectorIndex];
                }
            }

            destination.y = FloorYOffset;

            Vector3 nouvellePosition = Vector3.MoveTowards(actor.transform.position, destination, pas);
            Vector3 mouvement        = new Vector3(nouvellePosition.x - actor.transform.position.x, nouvellePosition.y - actor.transform.position.y, nouvellePosition.z - actor.transform.position.z);

            float angle = Mathf.Atan2(mouvement.x, mouvement.z) * Mathf.Rad2Deg;

            actor.transform.position = nouvellePosition;
            actor.transform.rotation = Quaternion.AngleAxis(angle, Vector3.up);
        }
Esempio n. 20
0
    public void RocketingDone()
    {
        Rocketing = false;
        BirdPowerup.SetActive(false);

        if (JustMovedRight == true)
        {
            GoTarget = MoveTarget.topRight;
        }

        else if (JustMovedRight == false)
        {
            GoTarget = MoveTarget.topLeft;
        }
    }
    // attaches the MoveTarget component to the GameObject, configuring its angle of movement and speed.
    private void AttachMoveComponent(GameObject obj, float angle)
    {
        MoveTarget moveTarget = obj.AddComponent(typeof(MoveTarget)) as MoveTarget;

        // script must be disabled. the target itself will enable it after appearing.
        moveTarget.enabled = false;

        float totalAngle = Random.Range(0, maximumMovingAngle);
        float startAngle;
        float endAngle;

        if (angle - lowerAngle < (totalAngle / 2) && higherAngle - angle < (totalAngle / 2))
        {
            // the total angle is constrained by both limit angles.
            // set the angles to be as big as the difference between the limits and its actual angle.
            endAngle   = angle - lowerAngle;
            startAngle = higherAngle - angle;
        }
        else if (angle - lowerAngle < (totalAngle / 2))
        {
            // the total angle is only constrained by the lower angle.
            // set the start angle to be the difference between the angle and the lower angle, and add the remaining
            // to the other half of the total angle for the end angle.
            endAngle   = angle - lowerAngle;
            startAngle = ((totalAngle / 2) - (angle - lowerAngle)) + (totalAngle / 2);
        }
        else if (higherAngle - angle < (totalAngle / 2))
        {
            // the total angle is only constrained by the higher angle.
            // set the end angle to be the difference between the angle and the higher angle, and add the remaining
            // to the other half of the total angle for the start angle.
            endAngle   = ((totalAngle / 2) - (higherAngle - angle)) + (totalAngle / 2);
            startAngle = higherAngle - angle;
        }
        else
        {
            // the total angle is not constrained by any angle.
            // simply set the half of the total angle into the start and end angles of the script.
            startAngle = totalAngle / 2;
            endAngle   = totalAngle / 2;
        }

        moveTarget.startAngle = startAngle;
        moveTarget.endAngle   = endAngle;

        // Debug.Log("A: " + angle + " LA: " + lowerAngle + " HA: " + higherAngle + " TA: " + totalAngle + " SA: " + startAngle + " EA: " + endAngle);
        moveTarget.speed = movingTargetSpeed;
    }
Esempio n. 22
0
    private void UpdateMovement()
    {
        float translation = Input.GetAxis("Vertical") * speed;
        float straffe     = Input.GetAxis("Horizontal") * speed;

        translation *= Time.deltaTime;
        straffe     *= Time.deltaTime;

        Vector3 moveDir = new Vector3(straffe, 0, translation);

        MoveTarget.Translate((RotTarget.rotation * moveDir).SetY(0), Space.World);

        if (Input.GetKeyDown("escape"))
        {
            Cursor.lockState = CursorLockMode.None;
        }
    }
    /*
     * Metodo encargado de gestionar los efectos secundarios de los ataques, como bajadas de stats o estados alterados
     */
    IEnumerator RunMoveEffects(MoveEffects effects, Pokemon source, Pokemon target, MoveTarget moveTarget)
    {
        //Boosts
        if (effects.Boosts != null) //de momento solo contemplamos los ataques de estado que implican boosts
        {
            if (moveTarget == MoveTarget.Self)
            {
                source.ApplyBoosts(effects.Boosts);
            }
            else if (moveTarget == MoveTarget.Foe)
            {
                target.ApplyBoosts(effects.Boosts);
            }
        }

        //Status conditions
        if (effects.Status != ConditionID.none)
        {
            //TODO: Estamos suponiendo que el target del status es el enemigo y no uno mismo
            EffectResult result = target.SetStatus(effects.Status);

            if (result == EffectResult.AlreadyOne)
            {
                yield return(dialogBox.TypeDialog($"{source.CurrentMove.Base.Name} had no effect!"));
            }
            else if (result == EffectResult.Inmune)
            {
                yield return(dialogBox.TypeDialog($"{target.Base.Name} it's inmune!"));
            }
        }

        //Volatile Status conditions
        if (effects.VolatileStatus != ConditionID.none)
        {
            //TODO: Estamos suponiendo que el target del status es el enemigo y no uno mismo
            target.SetVolatileStatus(effects.VolatileStatus);
        }

        //Mostramos en el dialogo las bajadas y subidas de stats de ambos pokemons
        yield return(ShowStatusChanges(source));

        yield return(ShowStatusChanges(target));
    }
Esempio n. 24
0
    void NextTarget()
    {
        CancelInvoke();
        MoveTutorial.StartMoving();

        foreach (Falling go in fallingThings)
        {
            if (go != null)
            {
                go.GetComponent <Falling>().StopAimAssist();
            }
        }


        if (GoTarget == MoveTarget.topLeft)
        {
            GoTarget = MoveTarget.botLeft;
            return;
        }

        else if (GoTarget == MoveTarget.botLeft)
        {
            GoTarget       = MoveTarget.topRight;
            JustMovedRight = true;
            jump           = false;
            return;
        }

        else if (GoTarget == MoveTarget.topRight)
        {
            GoTarget = MoveTarget.botRight;
            return;
        }

        else if (GoTarget == MoveTarget.botRight)
        {
            jump           = false;
            JustMovedRight = false;
            GoTarget       = MoveTarget.topLeft;
            return;
        }
    }
Esempio n. 25
0
        public void MoveTo(Vector3 destination, float minDistance = 0.0f, Action onComplete = null, float onCompleteDelay = 0.0f,
                           float moveDelay = 0.0f, bool cancelSpecial = true, float speedMultiplier = 1.0f, float rotationSpeedMultiplier = 1.0f, Vector3?turnToWhileCompleting = null)
        {
            MoveTarget move = new MoveTarget()
            {
                destination             = destination,
                minDistance             = minDistance,
                onComplete              = onComplete,
                onCompleteDelay         = onCompleteDelay,
                moveDelay               = moveDelay,
                cancelSpecial           = cancelSpecial,
                speedMultiplier         = speedMultiplier,
                rotationSpeedMultiplier = rotationSpeedMultiplier,
                turnToWhileCompleting   = turnToWhileCompleting
            };

            moves.Add(move);

            UpdateState();
        }
    public void AnimateDestruction()
    {
        disappearSound.Play();

        Material mat = this.targetRigidbody.GetComponent <Renderer>().material;

        // StandardShaderUtils.ChangeRenderMode(mat, StandardShaderUtils.BlendMode.Transparent);
        mat.SetFloat("_Alpha", 0.8f);
        if (this.compass != null)
        {
            this.compass.DeleteTarget(this.gameObject);
        }
        if (hideCoroutine != null)
        {
            StopCoroutine(hideCoroutine);
        }
        if (sonarTrigger != null)
        {
            sonarTrigger.GetComponent <NearbySonarElement>().sonarElement.StopSound();
            Destroy(sonarTrigger);
        }
        DisableColliders();

        Light light = GetComponentInChildren <Light>();

        light.enabled = false;

        MoveTarget moveTarget = GetComponent <MoveTarget>();

        if (moveTarget != null)
        {
            moveTarget.enabled = false;
        }

        this.targetRigidbody.isKinematic = false;
        this.targetRigidbody.useGravity  = true;
        this.targetRigidbody.AddRelativeForce(Vector3.right * 5f, ForceMode.Impulse);

        // Destroy after 3 seconds.
        StartCoroutine((this.gameObject.AddComponent(typeof(DestructionScheduler)) as DestructionScheduler).DestroyAfterTime(3f));
    }
Esempio n. 27
0
    // Use this for initialization
    void Start()
    {
        Roof         = FindObjectOfType <SpawnRoof>();
        GoTarget     = MoveTarget.topRight;
        score        = FindObjectOfType <Score>();
        Background   = FindObjectOfType <ScrollingBackground>();
        MoveTutorial = FindObjectOfType <MoveTutorialDown>();
        anim         = GetComponent <Animator>();
        cube         = FindObjectsOfType <TutorialCube>();

        anim.speed = 0;

        if (score.DoubleCoins == true)
        {
            DoubleCoinsUI.SetActive(true);
        }
        else
        {
            DoubleCoinsUI.SetActive(false);
        }
    }
Esempio n. 28
0
    //on state move update
    public void On_Move_Update( float t )
    {
        //if target lost by some reason, stop, change to idle
        if (moveTarget == null)
        {
            Idle();
            return;
        }

        //get target position
        Vector3 targetPos = Vector3.zero;

        //if target is a position, just use the position as target
        if (moveTarget.type == MoveTarget.MoveTargetType.Position)
        {
            targetPos = moveTarget.targetPosition;
        }
        //if target is a character, adjust a offset to the target, might evaluate by weapon/skill/etc
        else if (moveTarget.type == MoveTarget.MoveTargetType.Character)
        {
            Vector3 _dir = GetDirectionToCharacter(moveTarget.targetObject, Vector3.zero);
            Vector3 offset = new Vector3( characterData.attackRange * (_dir.x > 0f ? -1 : 1), 0, 0);
            targetPos = moveTarget.targetObject.transform.position + offset;
        }

        //get the distance to target
        Vector3 dir = targetPos - transform.position;
        float dis = dir.magnitude;

        //if readlly near to target
        if (dis <= 3f)
        {
            //fix the position
            targetPos.z = 0f;
            transform.position = targetPos;

            //if reach target position, go to idle
            if (moveTarget.type == MoveTarget.MoveTargetType.Position)
            {
                moveTarget = null;
                Idle();
            }
            //if reach target character, then attack it
            else if (moveTarget.type == MoveTarget.MoveTargetType.Character)
            {
                Attack();
            }

            return;
        }

        //move the character position by speed * time
        transform.position = transform.position + dir.normalized * characterData.moveSpeed * Time.deltaTime;

        //adjust character face to direct
        {
            float s = dir.x > 0f ? 1 : -1;
            if (!characterData.defaultFaceToRight)
                s = -s;

            Vector3 scale = spriteRenderer.localScale;
            scale.x = Mathf.Abs(scale.x) * s;
            spriteRenderer.localScale = scale;
        }
    }
Esempio n. 29
0
 public MoveArchetype(string name, MoveType moveType, ElementType elementType,
     int maxPp, int power, int accuracy, DurationType durationType, int turnDuration, BattleEffectStageEffect battleEffectStageEffect, 
     EffectType effectType, EffectStart effectStart, MoveTarget moveTarget, 
     BattleEffectType battleEffectType, string battleEffectText)
 {
     Name = name;
     MoveType = moveType;
     ElementType = elementType;
     MaxPP = maxPp;
     Power = power;
     Accuracy = accuracy;
     TurnDuration = turnDuration;
     BattleEffectStageEffect = battleEffectStageEffect;
     EffectType = effectType;
     EffectStart = effectStart;
     MoveTarget = moveTarget;
     DurationType = durationType;
     BattleEffectType = battleEffectType;
     BattleEffectText = battleEffectText;
 }
Esempio n. 30
0
    //find a enemy as a target
    public MoveTarget SearchEnemy()
    {
        //if we have a target object already, just return it
        if (moveTarget != null && moveTarget.type == MoveTarget.MoveTargetType.Character )
            return moveTarget;

        MoveTarget tmpTarget = null;
        //find the nearest enemy in search range
        foreach (BattleCharacterController bcc in characters)
        {
            //not same category type, and not myself
            if (bcc.characterData.isPlayer != characterData.isPlayer && bcc != this)
            {
                float dis = GetDistanceToCharacter(bcc, Vector3.zero);
                if (dis < characterData.enemySearchRange)
                {
                    if (tmpTarget == null)
                        tmpTarget = new MoveTarget(bcc);
                    else
                    {
                        float lastTargetDis = GetDistanceToCharacter(tmpTarget.targetObject, Vector3.zero);

                        if (dis < lastTargetDis)
                            tmpTarget.targetObject = bcc;
                    }
                }
            }
        }

        return tmpTarget;
    }
Esempio n. 31
0
 public void RocketState()
 {
     GoTarget = MoveTarget.rocket;
 }
Esempio n. 32
0
 public void SetTarget(MoveTarget _target)
 {
     target = _target;
 }
Esempio n. 33
0
    //moved this out of Runmove as there will hopefully be a lot of stats changes in here in the future
    IEnumerator RunMoveEffects(MoveEffects effects, Creature source, Creature target, MoveTarget moveTarget)
    {
        //var effects = move.Base.Effects;

        //stat boosting
        if (effects.Boosts != null)
        {
            //see if the move is targeting what creature, self boost or decline on enemy
            if (moveTarget == MoveTarget.self)
            {
                source.ApplyBoosts(effects.Boosts);
            }
            else
            {
                target.ApplyBoosts(effects.Boosts);
            }
        }

        //check if this move will cause a status condition
        if (effects.Status != ConditionsID.none)
        {
            target.SetStatus(effects.Status);
        }

        //check if this move will cause a Volitilestatus condition
        if (effects.VolitileStatus != ConditionsID.none)
        {
            target.SetVolitileStatus(effects.VolitileStatus);
        }

        //now we apply the boost we show the status function to either
        yield return(ShowStatusChanges(source));

        yield return(ShowStatusChanges(target));
    }
Esempio n. 34
0
    //these On_xxx_xxx function called by BehaviourController with SendMessage
    //on state idle update
    public void On_Idle_Update(float dt)
    {
        //we are idle, try to find a enemy
        MoveTarget tmp =  SearchEnemy();

        //if got one
        if ( tmp != null )
        {
            float dis = GetDistanceToCharacter(tmp.targetObject, Vector2.zero);
            float yDis = Mathf.Abs(tmp.targetObject.transform.position.y - transform.position.y);

            //if we can attack enemy immediatally? if yes, attack it, if no move to it
            if ( dis < characterData.attackRange && yDis < characterData.attackRange * 0.2f )
            {
                moveTarget = tmp;
                Attack();
            }
            else
                Move(tmp);
        }
    }
Esempio n. 35
0
 //change character state to move, and set the move target
 public void Move( MoveTarget target )
 {
     moveTarget = target;
     behaviourController.ChangeState("Move");
 }
Esempio n. 36
0
 public void HitRoof()
 {
     GoTarget = MoveTarget.falling;
 }