Пример #1
0
 // Use this for initialization
 void Start()
 {
     // initialize projectile spawning
     if (null == mProjectile)
     {
         mProjectile = Resources.Load("Prefabs/lvl1_egg") as GameObject;
     }
     mlastEggFire = Time.realtimeSinceStartup;
     mGameManager = GameObject.Find("GameManager").GetComponent <lvl1_GB>();
 }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     NewDirection();
     mGameManager = GameObject.Find("GameManager").GetComponent <lvl1_GB>();
     mHero        = GameObject.Find("Hero").GetComponent <lvl1_IC>();
     mRenderder   = gameObject.GetComponent <SpriteRenderer>();
     mState       = EnemyState.Normal;
     mSpeed       = kReferenceSpeed;
     mHits        = 0;
     wasScary     = false;
 }
Пример #3
0
    // New direction will be something randomly within +- 45-degrees away from the direction
    // towards the center of the world
    private void NewDirection()
    {
        lvl1_GB globalBehavior = GameObject.Find("GameManager").GetComponent <lvl1_GB>();

        // we want to move towards the center of the world
        Vector2 v = globalBehavior.WorldCenter - new Vector2(transform.position.x, transform.position.y);

        // this is vector that will take us back to world center
        v.Normalize();
        Vector2 vn = new Vector2(v.y, -v.x); // this is a direciotn that is perpendicular to V

        float useV      = 1.0f - Mathf.Clamp(kTowardsCenter, 0.01f, 1.0f);
        float tanSpread = Mathf.Tan(useV * Mathf.PI / 2.0f);

        float randomX = Random.Range(0f, 1f);
        float yRange  = tanSpread * randomX;
        float randomY = Random.Range(-yRange, yRange);

        Vector2 newDir = randomX * v + randomY * vn;

        newDir.Normalize();
        transform.up = newDir;
    }
Пример #4
0
 void Start()
 {
     mGameManager = GameObject.Find("GameManager").GetComponent <lvl1_GB>();
     mGameManager.addEggCount();
 }