Inheritance: TweenBase
Example #1
0
    void Start()
    {
        //add reference of this script to PoolManager's Properties dictionary,
        //this gets accessed by Projectile.cs on hit so we don't need a GetComponent call every time
        PoolManager.Props.Add(gameObject.name, this);

        //get movement reference
        myMove = gameObject.GetComponent <TweenMove>();
        //get animation component
        anim = gameObject.GetComponentInChildren <Animation>();

        //initialize our maxSpeed value once, at game start.
        //we don't need and want to set that on every spawn ( OnSpawn() )
        //because the last enemy could have altered it at runtime (via slow)
        myMove.maxSpeed = myMove.speed;
        //also get this gameobject ID once, at runtime it stays the same
        myMove.pMapProperties.myID = gameObject.GetInstanceID();

        //get healthbar/shield slider transform for rotating it later
        if (healthbar)
        {
            barParentTrans = healthbar.transform.parent.GetComponent <RectTransform>();
        }
        else if (shield.bar)
        {
            barParentTrans = shield.bar.transform.parent.GetComponent <RectTransform>();
        }

        //apply passive powerups to this enemy
        PowerUpManager.ApplyToSingleEnemy(this, myMove);
    }
 //static access for applying a powerup to a single enemy
 //used when spawning new enemies
 public static void ApplyToSingleEnemy(Properties prop, TweenMove move)
 {
     for (int i = 0; i < instance.passivePowerUps.Count; i++)
     {
         if (instance.passivePowerUps[i].enabled)
         {
             instance.passivePowerUps[i].ApplyToEnemy(prop, move);
         }
     }
 }
Example #3
0
 // Use this for initialization
 void Start()
 {
     shotPointsRight = new GameObject[] { shotPoints [0], shotPoints[2] };
     shotPointsLeft  = new GameObject[] { shotPoints [1], shotPoints[3] };
     anim            = GetComponent <Animator> ();
     autoMove        = GetComponent <AutoMove> ();
     pathComponent   = GetComponent <TweenMove> ();
     target          = GetComponent <Target> ();
     target.dead.AddListener(AfterDead);
     controller = GameObject.FindObjectOfType <GameController> ();
 }
Example #4
0
    // Use this for initialization
    void Start()
    {
        m_poses.Add(transform.FindChild("Left"));
        m_poses.Add(transform.FindChild("Middle"));
        m_poses.Add(transform.FindChild("Right"));

        m_player           = Instantiate(Resources.Load("Prefabs/Player")) as GameObject;
        m_playerController = m_player.AddComponent <TweenMove>();
        m_playerAnim       = m_player.animation;
        m_playerAnim.Play("runforward");
        m_playerController.SetTarget(m_poses[m_curPos]);
    }
Example #5
0
    public void InitData(EnemyNode enemy)
    {
        this.enemy = enemy;
        TweenMove move = gameObject.AddComponent <TweenMove>();

        move.from     = transform.position;
        move.to       = enemy.transform;
        move.duration = 0.5f;
        move.PlayForward();

        mSprite = GetComponent <UISprite>();
    }
Example #6
0
 void Start()
 {
     //store shuriken particle system and movement script
     pSys   = GetComponentInChildren <ParticleSystem>();
     myMove = GetComponent <TweenMove>();
     //set path of movement script
     myMove.pathContainer = pathToFollow;
     myMove.maxSpeed      = myMove.speed;
     //let this object follow the path
     myMove.StartCoroutine("OnSpawn");
     //start emitting particles while moving
     StartCoroutine("EmitParticles");
 }
Example #7
0
    public void ApplyToEnemy(Properties prop, TweenMove move)
    {
        //only affect selected enemies
        string myName = prop.name;

        if (!selectedEnemies.Contains(myName.Substring(0, myName.Length - 10)))
        {
            return;
        }

        //Properties variables
        //health, substract health and max health
        if (enemyProperties.health.enabled)
        {
            float healthDiff = prop.maxhealth;
            if (prop.maxhealth == 0)
            {
                prop.maxhealth = prop.health;
            }
            if (enemyProperties.health.type == TDValue.fix)
            {
                prop.maxhealth += enemyProperties.health.value;
            }
            else
            {
                prop.maxhealth = Round(prop.maxhealth, enemyProperties.health.value);
            }
            prop.health -= healthDiff - prop.maxhealth;
            prop.health  = Mathf.Clamp(prop.health, 1, prop.maxhealth);
        }

        //shield value, substracts value and max value
        if (enemyProperties.shield.enabled)
        {
            float shieldDiff = prop.shield.maxValue;
            if (prop.shield.maxValue == 0)
            {
                prop.shield.maxValue = prop.shield.value;
            }
            if (enemyProperties.shield.type == TDValue.fix)
            {
                prop.shield.maxValue += enemyProperties.shield.value;
            }
            else
            {
                prop.shield.maxValue = Round(prop.shield.maxValue, enemyProperties.shield.value);
            }
            prop.shield.value -= shieldDiff - prop.shield.maxValue;
            prop.shield.value  = Mathf.Clamp(prop.shield.value, 0, prop.shield.maxValue);
        }

        //refresh hud bars
        if (enemyProperties.health.enabled || enemyProperties.shield.enabled)
        {
            prop.SetUnitFrame();
        }

        //points to earn
        if (enemyProperties.pointsToEarn.enabled)
        {
            for (int j = 0; j < prop.pointsToEarn.Length; j++)
            {
                if (enemyProperties.pointsToEarn.type == TDValue.fix)
                {
                    prop.pointsToEarn[j] += enemyProperties.pointsToEarn.value[j];
                }
                else if (towerProperties.cost.costType == CostType.intValue)
                {
                    prop.pointsToEarn[j] = (int)(prop.pointsToEarn[j] * enemyProperties.pointsToEarn.value[j]);
                }
                else
                {
                    prop.pointsToEarn[j] = Round(prop.pointsToEarn[j], enemyProperties.pointsToEarn.value[j]);
                }
            }
        }

        //damage to deal
        if (enemyProperties.damageToDeal.enabled)
        {
            if (enemyProperties.damageToDeal.type == TDValue.fix)
            {
                prop.damageToDeal += (int)enemyProperties.damageToDeal.value;
            }
            else
            {
                prop.damageToDeal = (int)(prop.damageToDeal * enemyProperties.damageToDeal.value);
            }
        }

        //TweenMove variables
        //speed, permanently changes tween timescale
        if (enemyProperties.speed.enabled)
        {
            float curValue = move.maxSpeed;
            if (enemyProperties.speed.type == TDValue.fix)
            {
                move.maxSpeed += enemyProperties.speed.value;
            }
            else
            {
                move.maxSpeed = Round(move.maxSpeed, enemyProperties.speed.value);
            }
            move.speed = move.maxSpeed;

            if (move.tween != null)
            {
                move.tScale *= move.maxSpeed / curValue;
                if (move.tween.timeScale > move.tScale)
                {
                    move.tween.timeScale = move.tScale;
                }
            }
        }
    }
Example #8
0
    void Start()
    {
        //add reference of this script to PoolManager's Properties dictionary,
        //this gets accessed by Projectile.cs on hit so we don't need a GetComponent call every time
        PoolManager.Props.Add(gameObject.name, this);

        //get movement reference
        myMove = gameObject.GetComponent<TweenMove>();
        //get animation component
        anim = gameObject.GetComponentInChildren<Animator>();
        //anim = gameObject.GetComponentInChildren<Animation>();

        //get healthbar/shield slider transform for rotating it later
        if (healthbar)
            barParentTrans = healthbar.transform.parent;
        else if (shield.bar)
            barParentTrans = shield.bar.transform.parent;
    }
        public void EaseMoveGameObject(GameObject objectToMove, Vector3 targetPosition, float speed, Func <float, float> easeMethod)
        {
            var newTween = new TweenMove(objectToMove, targetPosition, speed, easeMethod);

            _moveTween.Add(newTween);
        }