示例#1
0
    public Vector3 DoMovement()
    {
        if (_SavedMovement != AnimatorInfo.MovementType)
        {
            ChangedMovementType = true;
            _SavedMovement      = AnimatorInfo.MovementType;
        }

        if (AnimatorInfo.MovementType == 0)          //0 == With Pathfinding And Walking From Node To Node
        {
            myVariables.GetNodeInfo().MyAStar.StartRunning(myVariables.GetObjectNodeInfo(), myVariables.GetNodeInfo(), myVariables.GetWhatToTarget().MyMovementTarget);

            if (myVariables.GetNodeInfo().MyNodePath [2] == null)            //If There Is Less Then 2 Nodes Left, Including That StartNode;
            {
                return(Vector3.zero);
            }
            if (myVariables.GetNodeInfo().MyNodePath [1] == null)
            {
                return(Vector3.zero);
            }
            else
            {
                MovementVector.x = ((myVariables.GetNodeInfo().MyNodePath [1].PosX - (myVariables.GetNodeInfo().MyNodePath [0].PosX)));
                MovementVector.y = ((myVariables.GetNodeInfo().MyNodePath [1].PosY - (myVariables.GetNodeInfo().MyNodePath [0].PosY)));
            }

            return(MovementVector.normalized);
        }
        else if (AnimatorInfo.MovementType == 1)            //Direct Targeting

        {
            MovementVector = (myVariables.GetWhatToTarget().MyMovementTarget.transform.position - myVariables.transform.position).normalized;


            return(MovementVector);
        }
        else if (AnimatorInfo.MovementType == 2)            //Locked Direct Targeting

        {
            if (ChangedMovementType == true)
            {
                ChangedMovementType = false;

                MovementVector = (myVariables.GetWhatToTarget().MyMovementTarget.transform.position - myVariables.transform.position).normalized;


                return(MovementVector);
            }


            return(MovementVector);
        }
        else            //Locking My Vector;


        {
            return(MovementVector);
        }
    }
    public override void SetMethod(CreatureRoot manager)
    {
        _MyObject        = manager;
        MyAnimator       = GetComponent <Animator> ();
        transform.parent = _MyObject.transform.Find("GFX");

        for (int t = 0; t < _MyObject.GetAbilityInfo().tes.Count; t++)                                 //Goint Through The Transitions To Find This Spell Transition
        {
            for (int g = 0; g < _MyObject.GetAbilityInfo().tes [t].AllAbilities.Length; g++)           //Going Through This Spells Transition To Find The Spell
            {
                if (_MyObject.GetAbilityInfo().tes [t].AllAbilities [g].SpellRef.bulletID == bulletID) //If SpellRef ID == This SpellID. Then This Is That Spell
                {
                    test [0] = _MyObject.GetAbilityInfo().tes [t].AllAbilities [g];
                }
            }
        }

        transform.localPosition = Quaternion.Euler(0, transform.parent.rotation.y, transform.parent.rotation.z) * test [0].SpawnPosition;         //Setting The Start Location

        if ((_MyObject.GetWhatToTarget().MyMovementTarget.transform.position - transform.position).y < 0)
        {
            transform.rotation = Quaternion.Euler(0, 0, Vector3.Angle(Vector3.right, (_MyObject.GetWhatToTarget().MyMovementTarget.transform.position - transform.position)) * -1);
        }
        else
        {
            transform.rotation = Quaternion.Euler(0, 0, Vector3.Angle(Vector3.right, (_MyObject.GetWhatToTarget().MyMovementTarget.transform.position - transform.position)));
        }
    }
 public override int RunCriteriaCheck(CreatureRoot objectChecking)     //This Return True If All Criteria To Start Is Met.
 {
     if (Vector3.Distance(objectChecking.transform.position, objectChecking.GetWhatToTarget().MyMovementTarget.transform.position) < DistanceToTarget)
     {
         if (Physics2D.LinecastAll(objectChecking.transform.position, objectChecking.GetWhatToTarget().MyMovementTarget.transform.position, WhatToNotGoThrough).Length == 0)
         {
             if (objectChecking.GetAnimatorVariables().AnimatorStage == 0)
             {
                 return(2);
             }
         }
         return(0);
     }
     else
     {
         return(0);
     }
 }
示例#4
0
 public override int RunCriteriaCheck(CreatureRoot objectChecking)     //This Return 'True' (Which Is AnimatorState Number) If All Criteria To Start Is Met.
 {
     if (Vector3.Distance(objectChecking.transform.position, objectChecking.GetWhatToTarget().MyMovementTarget.transform.position) < DistanceToTarget)
     {
         if (objectChecking.GetAnimatorVariables().AnimatorStage == 0)
         {
             return(1);
         }
         else
         {
             return(0);
         }
     }
     else
     {
         return(0);
     }
 }
示例#5
0
    void FixedUpdate()
    {
        //	if (_MyObject == null)//When Shooting Object Dies, Destroy This Object
        //		Destroy (this.gameObject);

        if (TargetClose == false)
        {
            if (Vector3.Distance(transform.position, _MyObject.GetWhatToTarget().MyMovementTarget.transform.position) < test [0].SpellVariables [4])
            {
                TargetClose = true;
                _MyObject.GetAnimatorVariables().SetAnimatorStage(2);
                _MyObject.Stats.Speed += test [0].SpellVariables [1];
                timeLeft = ClockTest.TheTimes + (test [0].SpellVariables [2]);
            }
            else
            {
                if (timeLeft < ClockTest.TheTimes)                           //Time To Scout
                {
                    _MyObject.GetAnimatorVariables().SetAnimatorStage(1000); //1000 - 1010 Is Values Used For The Purpose Of Animator State Changes Which Isnt Similar To Any Spell 'ID'
                    _MyObject.GetAbilityInfo().AddLostTime(bulletID);
                    _MyObject.GetAnimatorVariables().AbilityRunning = false;
                    Destroy(this.gameObject);
                }
            }
        }
        else
        {
            if (attackTime < ClockTest.TheTimes)
            {
                attackTime = ClockTest.TheTimes + (test [0].SpellVariables [3]);
                Instantiate(MoulySpikes, transform.position, Quaternion.identity).SetMethod(_MyObject);
            }

            if (timeLeft < ClockTest.TheTimes)                           //Time To Scout
            {
                _MyObject.GetAnimatorVariables().SetAnimatorStage(1000); //1000 - 1010 Is Values Used For The Purpose Of Animator State Changes Which Isnt Similar To Any Spell 'ID'
                _MyObject.Stats.Speed -= test [0].SpellVariables [1];

                _MyObject.GetAbilityInfo().AddLostTime(bulletID);
                _MyObject.GetAnimatorVariables().AbilityRunning = false;
                Destroy(this.gameObject);
            }
        }
    }
    public override void SetMethod(CreatureRoot objectChecking)
    {
        /*	_MyObject = objectChecking;
         *      parentRotaitons = _MyObject.transform.Find("GFX").rotation;
         *
         *      for (int t = 0; t < _MyObject.MyAbilityInfo.tes.Count; t++) {//Goint Through The Transitions To Find This Spell Transition
         *              for (int g = 0; g < _MyObject.MyAbilityInfo.tes [t].AllAbilities.Length; g++) {//Going Through This Spells Transition To Find The Spell
         *                      if (_MyObject.MyAbilityInfo.tes [t].AllAbilities [g].SpellRef.bulletID == bulletID) {//If SpellRef ID == This SpellID. Then This Is That Spell
         *                              teste [0] = _MyObject.MyAbilityInfo.tes [t].AllAbilities [g];
         *                      }
         *              }
         *      }
         *
         *
         *
         *
         *
         *
         *      foundIt = false;
         *
         *      for (int i = 0; i < rngtries; i++) {
         *              test = (Quaternion.Euler (0, 0, Random.Range (1, rngtries + 1) * Random.Range (0, 90)) * (Vector3.right * TeleportDistance));//Deviding The Circle In 4, Then I Make Choose A RNG Side To Check
         *
         *              hitted = Physics2D.LinecastAll (objectChecking.Targeting.MyMovementTarget.transform.position + test, objectChecking.Targeting.MyMovementTarget.transform.position, WhatNotToHit);
         *              if (hitted.Length > 0) {
         *                      //		Debug.Log ("Hit Something " + hitted [hitted.Length - 1].point.x + " | " + hitted [hitted.Length - 1].point.y + " | " + test.normalized);
         *              } else {
         *                      foundIt = true;
         *                      //		Debug.Log ("No Wall Found");
         *                      test = objectChecking.Targeting.MyMovementTarget.transform.position + test;
         *                      i = rngtries;
         *              }
         *
         *      }
         *
         *      if (foundIt == false) {
         *              test = (Quaternion.Euler (0, 0, Random.Range (1, rngtries + 1) * Random.Range (0, 90)) * (Vector3.right * TeleportDistance));
         *              hitted = Physics2D.LinecastAll (objectChecking.Targeting.MyMovementTarget.transform.position + test, objectChecking.Targeting.MyMovementTarget.transform.position, WhatNotToHit);
         *              if (hitted.Length > 0) {
         *                      hitted = Physics2D.LinecastAll (objectChecking.Targeting.MyMovementTarget.transform.position, (Vector3)hitted [hitted.Length - 1].point, WhatNotToHit);
         *                      //	Debug.Log ( "Oposite Side Of Wall ");
         *                      test = (Vector3)(hitted [0].point) - (test.normalized * 0.05f);
         *
         *              } else {
         *                      //	Debug.Log ("No New Wall Found");
         *                      test = objectChecking.Targeting.MyMovementTarget.transform.position + test;
         *              }
         *      }
         *
         *      objectChecking.transform.position = test;
         *      transform.position = objectChecking.transform.position + Quaternion.Euler (0, parentRotaitons.y, parentRotaitons.z) * teste [0].SpawnPosition;//Setting The Start Location
         *
         *      _Direction.z = Vector3.Angle (Vector3.right, (objectChecking.Targeting.MyMovementTarget.transform.position - objectChecking.transform.position));
         *
         *      if ((objectChecking.Targeting.MyMovementTarget.transform.position - objectChecking.transform.position).y < 0) {
         *              _Direction.z = _Direction.z * -1.0f;
         *      }
         *      transform.rotation = Quaternion.Euler (_Direction);
         *
         *      gameObject.SetActive(true);
         *      Particleeffect.GetComponent<MoveForwardFast> ().starting = true;
         *
         *
         *      hitted = Physics2D.LinecastAll (transform.position, ((objectChecking.Targeting.MyMovementTarget.transform.position - objectChecking.transform.position).normalized * teste[0].SpellVariables[1]), WhatNotToHit);
         *
         *      hitted = Physics2D.BoxCastAll (transform.position, boxSize, _Direction.z,  ((Vector2)transform.position - hitted[0].point).normalized, 0, StopOnHit );
         *      Debug.Log ("HIT " + hitted.Length);*/

        //	Physics2D.BoxCastAll();

        //	_MyObject = GameObject.Find ("Otaku_Boss").GetComponent<EnemyManaging>();

        hitted = Physics2D.LinecastAll(transform.position, (Vector2)transform.position + (Vector2.right * 3), WhatNotToHit);
        hitted = Physics2D.BoxCastAll(transform.position, boxSize, 0, Vector2.right, 0, StopOnHit);
        //	hitted = Physics2D.BoxCastAll (transform.position, boxSize, 0,  ((Vector2)transform.position - hitted[0].point).normalized, 0, StopOnHit );

        ShootingVector        = objectChecking.GetWhatToTarget().TargetVector - transform.position;  //Vector from My Position To The Target
        transform.eulerAngles = (Quaternion.Euler(0, 0, transform.eulerAngles.z) * Vector2.right);
    }
示例#7
0
 public void SetTargetVectorToTarget()
 {
     myVariables.GetWhatToTarget().SetTargetVectorToTarget();
 }
    void FixedUpdate()
    {
        if (_StartMoving == true)
        {
            if (Dieing == false)
            {
                if (RemoveParent == false)
                {
                    RemoveParent        = true;
                    transform.parent    = null;
                    MyShootingDirection = MyShootingDirection.normalized;
                }

                transform.position += MyShootingDirection * test [0].SpellVariables [1] * Time.deltaTime;

                _ObjectHit = Physics2D.CircleCastAll(transform.position + (Vector3.right * 0.02f), test [0].SpellVariables [2], Vector2.zero, 1, WhatCanIHit);

                if (_ObjectHit.Length > 0)
                {
                    foreach (RaycastHit2D s in _ObjectHit)
                    {
                        if (s.transform.gameObject.layer == 8 || s.transform.gameObject.layer == 15)
                        {
                            targets = s.transform.GetComponent <CreatureRoot> ();
                            if (targets != null)
                            {
                                if (targets.Stats.HealthImmunity == false && targets.Stats.TotalImmunity == false)
                                {
                                    if (test [0].SpellVariables [0] * (1 - targets.Stats.PhysicalResistence) > 0)                                      //If The Creature Have Resist > 1 Then The Attack Will Heal The Creature. Fire On Fire Might Heal?
                                    {
                                        targets.TookDmg(Mathf.CeilToInt(test [0].SpellVariables [0] * (1 - targets.Stats.PhysicalResistence)));
                                    }
                                }
                            }
                        }
                    }

                    Dieing = true;
                    MyAnimator.SetInteger("SpellState", 1);
                }
            }
            else
            {
                transform.position += (MyShootingDirection * Time.deltaTime) / 2;
            }
        }
        else
        {
            MyShootingDirection = _MyObject.GetWhatToTarget().MyMovementTarget.transform.position - transform.position;

            if (MyShootingDirection.y < 0)
            {
                transform.rotation = Quaternion.Euler(0, 0, Vector3.Angle(Vector3.right, MyShootingDirection) * -1);
            }
            else
            {
                transform.rotation = Quaternion.Euler(0, 0, Vector3.Angle(Vector3.right, MyShootingDirection));
            }
            transform.localPosition = Quaternion.Euler(0, transform.parent.rotation.y, transform.parent.rotation.z) * test [0].SpawnPosition;
        }
    }
    public override int RunCriteriaCheck(CreatureRoot objectChecking)                  //This Return True If All Criteria To Start Is Met. TODO Setup The New Collision System
    {
        if (objectChecking.GetAnimatorVariables().AnimatorStage == AnimatorStateCheck) //If The Animator Have Reached The Correct Point Then This Is False
        {
            return(0);
        }
        else
        {
            //Searching If There Is A Free Spot On A Rng Based Rotation.

            foundIt = false;

            for (int i = 0; i < rngtries; i++)                                                                                               //Going Through To Check If There Are Any Spots Around Target That Isnt busy/taken
            {
                test   = (Quaternion.Euler(0, 0, Random.Range(1, rngtries + 1) * Random.Range(0, 90)) * (Vector3.right * TeleportDistance)); //Deviding The Circle In 4, Then I Make Choose A RNG Side To Check
                hitted = Physics2D.LinecastAll(objectChecking.GetWhatToTarget().MyMovementTarget.transform.position + test, objectChecking.GetWhatToTarget().MyMovementTarget.transform.position, WhatNotToHit);

                if (hitted.Length == 0)                  //Didnt Hit Anything
                {
                    foundIt = true;
                    test    = objectChecking.GetWhatToTarget().MyMovementTarget.transform.position + test;
                    i       = rngtries;
                }
            }

            if (foundIt == false)              //If There Were No Free Location To Teleport To, Do 1 More And Then If Still False, Force Teleport As Close To The Target As Possible
            {
                test   = (Quaternion.Euler(0, 0, Random.Range(1, rngtries + 1) * Random.Range(0, 90)) * (Vector3.right * TeleportDistance));
                hitted = Physics2D.LinecastAll(objectChecking.GetWhatToTarget().MyMovementTarget.transform.position + test, objectChecking.GetWhatToTarget().MyMovementTarget.transform.position, WhatNotToHit);

                if (hitted.Length > 0)                  //Hit Something
                {
                    hitted = Physics2D.LinecastAll(objectChecking.GetWhatToTarget().MyMovementTarget.transform.position, (Vector3)hitted [hitted.Length - 1].point, WhatNotToHit);
                    test   = (Vector3)(hitted [0].point) - (test.normalized * 0.05f);
                }
                else                    //Didnt Hit Anything
                {
                    test = objectChecking.GetWhatToTarget().MyMovementTarget.transform.position + test;
                }
            }

            //Then A Check Needs To Be Made If The Ground Is Walkable Or Not, A Cliff Edge Or A Sea Of Magma ETC..
//TODO Commented Out This				if (objectChecking.GetNodeInfo ().MyAStar._WalkCost.ValidPositions (objectChecking.GetNodeInfo ().MyAStar._WalkCost.GetXPos(Mathf.RoundToInt( test.x / StressCommonlyUsedInfo.DistanceBetweenNodes)), objectChecking.GetNodeInfo ().MyAStar._WalkCost.GetYPos(Mathf.RoundToInt(test.y / StressCommonlyUsedInfo.DistanceBetweenNodes))) == false)
//TODO Commented Out This				return 0;


            //	if (objectChecking.GetNodeInfo ().MyAStar._WalkCost.ValidPositions (objectChecking.GetObjectNodeInfo ().MyCollisionInfo.XNode, objectChecking.GetObjectNodeInfo ().MyCollisionInfo.YNode) == false)
            //		return 0;

            //If A Spot Was Found,


            /*
             * //If Nothing Collides With The Object
             *
             * if (objectChecking.GetNodeInfo ().MyAStar._WalkCost.ValidPositions (objectChecking.GetObjectNodeInfo ().MyCollisionInfo.XNode, objectChecking.GetObjectNodeInfo ().MyCollisionInfo.YNode) == false)
             *      return 0;
             *
             * theX = objectChecking.GetNodeInfo ().MyAStar._WalkCost.GetXPos (objectChecking.GetObjectNodeInfo ().MyCollisionInfo.XNode);
             * theY = objectChecking.GetNodeInfo ().MyAStar._WalkCost.GetYPos (objectChecking.GetObjectNodeInfo ().MyCollisionInfo.YNode);
             *
             * if (objectChecking.GetNodeInfo ().MyAStar._WalkCost.BaseGroundLayer [theX, theY] == 1) {//If ID == Wall, Return 'False'.
             *      return 0;
             * }
             *
             * iterations = objectChecking.GetNodeInfo ().MyAStar._WalkCost.CollisionAmount [theX, theY];
             *
             * for (int i = 0; i < iterations; i++) {//Iterating Through The Taken Collision IDs
             *      if (objectChecking.GetNodeInfo ().MyAStar._WalkCost.CollisionMap [theX, theY, i].NodesCollisionID == 1) {//If ID == Wall, Return 'False'.
             *              return 0;
             *      }
             * }
             *
             * if (objectChecking.GetAnimatorVariables ().AnimatorStage != 0)
             *      return 0;
             */
        }

        return(3);       //If Nothing Failed, Return 'True'.
    }