Exemple #1
0
    IEnumerator Slow()
    {
        //Debug.LogError ("No Grape found? PANIC!");
        temp        = enemies[0].GetComponent <EnemyAI>();
        temp.speed  = 50f;
        temp.speed1 = 0.1f;
        temp        = enemies[1].GetComponent <EnemyAI>();
        temp.speed  = 50f;
        temp.speed1 = 0.1f;
        temp1       = enemies[2].GetComponent <GhostMovement>();
        temp1.speed = 0.1f;
        temp1       = enemies[3].GetComponent <GhostMovement>();
        temp1.speed = 0.1f;
        Debug.Log(temp.speed);
        yield return(new WaitForSeconds(7.0f));

        temp        = enemies[0].GetComponent <EnemyAI>();
        temp.speed  = 100f;
        temp.speed1 = 0.2f;
        temp        = enemies[1].GetComponent <EnemyAI>();
        temp.speed  = 100f;
        temp.speed1 = 0.2f;
        temp1       = enemies[2].GetComponent <GhostMovement>();
        temp1.speed = 0.2f;
        temp1       = enemies[3].GetComponent <GhostMovement>();
        temp1.speed = 0.2f;
        Destroy(gameObject);
    }
Exemple #2
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        // Is it damageable?
        DamageableEntity damageable = collision.gameObject.GetComponent <DamageableEntity>();

        if (damageable)
        {
            if (onHit != null)
            {
                onHit.Invoke(collision.gameObject);
            }
            // Deal your damage
            // Possibility of a persistent projectile / hit-point system?

            if (OnAttackHit != null)
            {
                OnAttackHit.Invoke();
            }
            damageable.TakeDamage(Damage);
        }

        // Is it a ghost?
        Transform parent = collision.gameObject.transform.parent;

        if (parent != null)
        {
            GhostMovement ghost = parent.GetComponentInChildren <GhostMovement>();
            if (ghost != null)
            {
                ghost.Knockback(transform.up * knockbackForce);
            }
        }
    }
 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);
         }
     }
 }
    public void CreateGhost(Vector3 pos)
    {
        if (GameManager.instance.SelectedGamemode != null)
        {
            if (GameManager.instance.SelectedGamemode.roundIsUnderway == false)
            {
                return;
            }
        }

        currentPlayerActionMap = "Ghost";
        if (playerInput != null)
        {
            playerInput.SwitchCurrentActionMap(currentPlayerActionMap);
        }

        currentGhost = Instantiate(ghostPrefab, pos, Quaternion.identity);
        currentGhost.transform.parent = transform;
        ghostMovement = currentGhost.GetComponent <GhostMovement>();
        ghostGrab     = currentGhost.GetComponent <GhostGrab>();
        ghostMovement.playerNumber   = playerNumber;
        ghostMovement.headAnimNumber = headIndex;
        ghostGrab.playerNumber       = playerNumber;
        ghostGrab.player             = this;
    }
Exemple #5
0
 void Start()
 {
     dash  = GetComponent <DashController>();
     move  = GetComponent <GhostMovement>();
     combo = GetComponent <GhostCombo>();
     fx    = GetComponent <FX>();
 }
Exemple #6
0
    IEnumerator MyMethod()
    {
        temp          = enemies [0].GetComponent <EnemyAI> ();
        temp.canmove1 = false;
        temp          = enemies [1].GetComponent <EnemyAI> ();
        temp.canmove1 = false;
        temp1         = enemies [2].GetComponent <GhostMovement> ();
        temp1.canmove = false;
        temp1         = enemies [3].GetComponent <GhostMovement> ();
        temp1.canmove = false;
        Restart();
        yield return(new WaitForSeconds(0.5f));

        Restart();
        yield return(new WaitForSeconds(8.0f));

        temp          = enemies[0].GetComponent <EnemyAI>();
        temp.canmove1 = true;
        temp.canmove  = true;
        temp          = enemies[1].GetComponent <EnemyAI>();
        temp.canmove1 = true;
        temp.canmove  = true;
        /////////////////////////////////////////////////
        temp1         = enemies[2].GetComponent <GhostMovement>();
        temp1.canmove = true;
        temp1         = enemies[3].GetComponent <GhostMovement>();
        temp1.canmove = true;
        Destroy(gameObject);
    }
Exemple #7
0
    public void Initialize(GhostAIStats stats)
    {
        this.stats = stats;
        stats.self = this;
        NotificationMaster.playerObservers.Add(this);

        float aggro = stats.Aggressiveness();

        if (aggro > 0)
        {
            attack = gameObject.AddComponent <GhostAttack>();
            GetComponent <GhostAttack> ().Initialize(stats);
        }

        movement = gameObject.GetComponent <GhostMovement>();
        movement.Initialize(stats);

        detectionRadius = Room.bounds.extents.x;

        transform.localScale = new Vector3(stats.size, stats.size, 1);

        size = GetComponent <SpriteRenderer>().bounds.extents;

        transform.position     = movement.GetSpawnPosition(size);
        movement.startPosition = transform.position;

        layerMask = 1 << LayerMask.NameToLayer("Wall") | 1 << LayerMask.NameToLayer("Player");

        GetComponent <SpriteRenderer>().sortingOrder = (int)(1.0f / size.magnitude * 1000);

        AdjustColors(aggro);

        animate = GetComponent <Animate>();
        animate.AnimateToColor(Palette.Invisible, color, .3f);
    }
Exemple #8
0
    public BlueGhostBehaviour(GhostMovement redGhostMovementHandler)
    {
        this.redGhostMovementHandler = redGhostMovementHandler;

        scatterGoalCellPos   = new Vector3Int(GhostManager.Instance.WallsTilemap.cellBounds.xMax, GhostManager.Instance.WallsTilemap.cellBounds.yMin, 0);
        dotsBeforeRelease    = 30;
        SecondsBeforeRelease = 15;
    }
Exemple #9
0
    void OnTriggerEnter2D(Collider2D other)
    {
        GhostMovement ghostMovement = other.GetComponent <GhostMovement>();

        if (ghostMovement)
        {
            // ghostMovement.CrossRoom();
        }
    }
Exemple #10
0
 public void GhostDied(GhostMovement movement)
 {
     if (!system.enableFSMControl)
     {
         // if its under individual control:
         IndividualFSMSystem s = movement.GetComponent <IndividualFSMSystem>();
         s.Transition("DeathState");
     }
 }
Exemple #11
0
    void Start()
    {
        if (Camera.main != null)
        {
            camerController = Camera.main.GetComponent <CameraController>();
            camerController.playersInGame.Add(transform);
        }

        ghostMovement = GetComponent <GhostMovement>();
    }
    private void OnCollisionEnter2D(Collision2D col)
    {
        GhostMovement ghost = col.collider.GetComponent <GhostMovement>();
        BatMovement   bat   = col.collider.GetComponent <BatMovement>();

        if (bat != null || ghost != null)
        {
            Hurt();
        }
    }
    private void Awake()
    {
        ghostMovement = GetComponent <GhostMovement>();

        if (ghostMovement == null)
        {
            Debug.Log("game object ghostMovement not found");
        }
        if (tileManager == null)
        {
            Debug.Log("game object tileManager not found");
        }
    }
 /// <summary>
 /// Sets Ghost stats depending on type of Ghost
 /// Example the Difficulty of the Ghost
 /// </summary>
 private void StartGhost()
 {
     _ghoststats = ActiveGhost.GetComponent <GhostMovement>();
     //Speed the Ghost moves around
     _ghoststats.Speed = 10f;
     //How far from position the next random target is set
     //_ghoststats.WanderRadius = 20f; NO LONGER BEING USED
     //Set the level of the ghost by RandomRate
     // Lower the number faster the movement
     _ghoststats.RandomRate = 4f;
     _ghoststats.Stuck      = false;
     StartCoroutine(_ghoststats.MoveAgent(5f));
     MiniGameStart = true;
 }
Exemple #15
0
 void OnCollisionEnter(Collision hit)
 {
     if (hit.transform.tag == "Ghost")
     {
         movement = hit.gameObject.GetComponent <GhostMovement>();
         if (changer == DirChanger.Horizontal)
         {
             movement.DirectionChanger(new Vector3(-1, 1, 0));
         }
         else if (changer == DirChanger.Vertical)
         {
             movement.DirectionChanger(new Vector3(1, -1, 0));
         }
     }
 }
Exemple #16
0
    // Use this for initialization
    void Awake()
    {
        pacman = FindObjectOfType <PacmanMove>();
        speed  = pacman.speed;

        if (type == GhostType.Chaser)         //store this so blue ghost can access it
        {
            chaseGhost = this;
        }

        start   = transform.position;
        dest    = start;
        atStart = true;
        Wait(delayAtStart);
    }    //Awake
Exemple #17
0
    // Update is called once per frame
    void OnTriggerEnter2D(Collider2D co)
    {
        Vector2 a = transform.position;

        if (co.name == "pacman")
        {
            //Destroy (co.gameObject);
            if (Lives == 3)
            {
                Lives--;
                Destroy(Life[0]);
                PlayDeath();
            }
            else if (Lives == 2)
            {
                Lives--;
                Destroy(Life[1]);
                PlayDeath();
            }
            else
            {
                Lives--;
                Destroy(Life[2]);
                PlayDeath();
            }
            if (Lives == 0)
            {
                StartCoroutine(Level());
            }
            StartCoroutine(MyMethod());
            temp      = enemies[0].GetComponent <EnemyAI>();
            temp.cur  = 0;
            temp      = enemies[1].GetComponent <EnemyAI>();
            temp.cur  = 0;
            temp1     = enemies[2].GetComponent <GhostMovement>();
            temp1.cur = 0;
            temp1     = enemies[3].GetComponent <GhostMovement>();
            temp1.cur = 0;
        }
        //Destroy(target);

        /*if (co.name == "wayPoint") {
         *      Vector2 a=transform.position;
         *      a.x=35;
         *      co.gameObject.transform.position=a;
         * }*/
    }
Exemple #18
0
 // Use this for initialization
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "pacman")
     {
         Vector2 a = transform.position;
         a.x = 100; a.y = 100;
         transform.position = a;
         StartCoroutine(MyMethod());
         temp      = enemies[0].GetComponent <EnemyAI>();
         temp.cur  = 0;
         temp      = enemies[1].GetComponent <EnemyAI>();
         temp.cur  = 0;
         temp1     = enemies[2].GetComponent <GhostMovement>();
         temp1.cur = 0;
         temp1     = enemies[3].GetComponent <GhostMovement>();
         temp1.cur = 0;
     }
 }
    private void SetMoveState(GhostMovement state)
    {
        Debug.Log("SetMoveState");
        moveState = state;

        switch (moveState)
        {
        case GhostMovement.Waiting:
            direction   = waitingStartDirection;
            waitingUp   = new Vector2(origin.x, origin.y + waitingMoveDistance);
            waitingDown = new Vector2(origin.x, origin.y - waitingMoveDistance);
            break;

        case GhostMovement.Moving:
            direction = Vector3Int.left;
            break;
        }
    }
Exemple #20
0
    IEnumerator MyMethod()
    {
        Debug.Log("Here");
        temp          = enemies[0].GetComponent <EnemyAI>();
        temp.canmove1 = false;
        temp          = enemies[1].GetComponent <EnemyAI>();
        temp.canmove1 = false;
        temp1         = enemies[2].GetComponent <GhostMovement>();
        temp1.canmove = false;
        temp1         = enemies[3].GetComponent <GhostMovement>();
        temp1.canmove = false;
        Restart();

        yield return(new WaitForSeconds(0.5f));

        Restart();
        yield return(new WaitForSeconds(3.5f));

        Vector2 a = transform.position;

        a.x = 15f; a.y = -30f;
        enemies [4].transform.position = a;

        temp          = enemies[0].GetComponent <EnemyAI>();
        temp.canmove1 = true;
        temp.canmove  = true;
        temp          = enemies[1].GetComponent <EnemyAI>();
        temp.canmove1 = true;
        temp.canmove  = true;
        /////////////////////////////////////////////////
        temp1         = enemies[2].GetComponent <GhostMovement>();
        temp1.canmove = true;
        temp1         = enemies[3].GetComponent <GhostMovement>();
        temp1.canmove = true;
        //temp = enemies[3].GetComponent<EnemyAI>();
        //temp.canmove1=true;
    }
 private void Awake()
 {
     zombieMovement = GameObject.FindObjectOfType <ZombieMovement>();
     ghostMovement  = GameObject.FindObjectOfType <GhostMovement>();
     camera         = GameObject.FindObjectOfType <CameraFollowPlayer>();
 }
Exemple #22
0
 void Awake()
 {
     frightenedTimeMax = 6f;
     GhostMovement.SetGhostHouseExitTiles(ghostHouseExitTile1, ghostHouseExitTile2);
 }
 void Awake()
 {
     anim = GetComponent<Animator> ();
     movement = GetComponent<GhostMovement> ();
     sphereCollider = GetComponent<SphereCollider> ();
 }
Exemple #24
0
 void Awake()
 {
     anim           = GetComponent <Animator> ();
     movement       = GetComponent <GhostMovement> ();
     sphereCollider = GetComponent <SphereCollider> ();
 }
Exemple #25
0
 // Use this for initialization
 void Awake()
 {
     pacman   = FindObjectOfType <PacmanDie>();
     animator = GetComponent <Animator>();
     movement = GetComponent <GhostMovement>();
 }    //Awake
 private void Awake()
 {
     movement         = GetComponent <GhostMovement>();
     animation        = GetComponent <GhostAnimation>();
     secondsPerAttack = 1 / attackSpeed;
 }