Exemplo n.º 1
0
    public void SpawnChaser()
    {
        GameObject chaser = Instantiate(chaserObject, spawnPosition, Quaternion.identity) as GameObject;

        chaser.transform.parent = gameObject.transform.parent;

        ChaserMovement chaserMovement = chaser.GetComponent <ChaserMovement>();

        if (chaserMovement == null)
        {
            return;
        }

        if (actionHistory == null)
        {
            Movement movement = gameObject.GetComponent <Movement>();

            if (movement != null)
            {
                actionHistory = movement.actionHistory;
            }
        }


        //#!
        if (chaserMovement is MonkeyMovement)
        {
            (chaserMovement as MonkeyMovement).target = gameObject;
        }
        else
        {
            chaserMovement.targetActions = actionHistory.GetEnumaration();
        }
    }
Exemplo n.º 2
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Despawner")
     {
         if (!info.getCarryingGold())
         {
             if (gameObject.name == "Small Grunt(Clone)" || gameObject.name == "Large Grunt(Clone)")
             {
                 EnemyMovement movement = this.GetComponent <EnemyMovement>();
                 movement.flipDirection();
             }
             else if (gameObject.name == "Ghost(Clone)")
             {
                 GhostMovement movement = this.GetComponent <GhostMovement>();
                 movement.flipXDirection();
             }
             else
             {
                 ChaserMovement movement = this.GetComponent <ChaserMovement>();
                 movement.flipDirection();
             }
         }
         else
         {
             // Destroy(gameObject);
             gameObject.SetActive(false);
         }
     }
 }
 void Start()
 {
     movement = gameObject.GetComponent <ChaserMovement>();
     info     = gameObject.GetComponent <EnemyInfo>();
     seeker   = gameObject.GetComponent <Seeker>();
     rb       = gameObject.GetComponent <Rigidbody2D>();
 }
Exemplo n.º 4
0
    void DiseaseCrowder(GameObject crowderBody)
    {
        PanicManager panicManager = PanicManager.Instance;

        // get real behaviour carrier
        GameObject crowderBehaviourGO = crowderBody.transform.gameObject;

        // cash crowder position
        Vector3 crowderPos = crowderBehaviourGO.transform.localPosition;

        // remove from victims' list and destroy
        panicManager.m_Spawner.m_Crowders.Remove(crowderBehaviourGO);
        Destroy(crowderBehaviourGO);

        GameObject zombi = Instantiate(panicManager.m_DiseasedPrefab, panicManager.m_DiseasedContainer) as GameObject;

        zombi.transform.localScale    = Vector3.one;
        zombi.transform.localPosition = crowderPos;

        ChaserMovement chaserBehaviour = zombi.GetComponent <ChaserMovement>();

        panicManager.m_Chasers.Add(chaserBehaviour);
        panicManager.m_PanicPoints.Add(chaserBehaviour.GetComponent <PanicPoint>());
        chaserBehaviour.Init();
    }
Exemplo n.º 5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        ChaserMovement movement = collision.GetComponent <ChaserMovement>(); //find unique movement component to Chasers

        if (movement != null && movement.isActiveAndEnabled)                 //if object hit is a Chaser (not first position player)
        {
            movement.Stun(Stun_Duration);
            Destroy(gameObject);
        }
    }
Exemplo n.º 6
0
 public PlayerComponents(GameObject r, int n, int h)
 {
     Reference = r;
     Rb        = r.GetComponent <Rigidbody2D>();
     Number    = n;
     Health    = h;
     Chaser    = r.GetComponent <ChaserMovement>();
     Leader    = r.GetComponent <LeaderMovement>();
     Gun       = r.GetComponent <BasicGun>();
 }
Exemplo n.º 7
0
    void OldDiseaseCrowder(GameObject crowderBody)
    {
        // get real behaviour carrier
        GameObject crowderBehaviourGO = crowderBody.transform.parent.gameObject;

        // rename to diseased
        crowderBody.tag        = "Zombi";
        crowderBehaviourGO.tag = "Zombi";

        // disable crowder component
        crowderBehaviourGO.GetComponent <PanicMovement>().enabled = false;

        // introduce disease component
        Disease newZombi = crowderBody.AddComponent <Disease>();

        newZombi.m_Body = newZombi.gameObject.GetComponent <Rigidbody>();

        // introduce panic component
        PanicPoint panicSource = crowderBehaviourGO.AddComponent <PanicPoint>();

        panicSource.m_FearStrength = 1;

        // introduce chaser component
        ChaserMovement chaserBehaviour = crowderBehaviourGO.AddComponent <ChaserMovement>();

        chaserBehaviour.m_Disease = newZombi;

        // change material
        Material newZombiMaterial = newZombi.m_Body.gameObject.GetComponent <Material>();

        newZombiMaterial = PanicManager.Instance.m_DiseaseMaterial;

        PanicManager.Instance.m_Chasers.Add(chaserBehaviour);
        PanicManager.Instance.m_PanicPoints.Add(panicSource);
        chaserBehaviour.Init();
    }
Exemplo n.º 8
0
 protected new void Start()
 {
     base.Start();
     chaserMovement = GetComponent <ChaserMovement>();
 }