예제 #1
0
    public void TileClicked(Tile tile)
    {
        //Depending on your mode it will do different stuff.
        if (curUserState == UserStates.cultist)
        {
            //Okay!
            SpawnCultist(tile);
            PlayCastClip();
        }
        else if (curUserState == UserStates.knight)
        {
            //Was used for debugging
        }
        else if (curUserState == UserStates.cultist_taskmaster)
        {
            Cultist tileCultist = tile.GetComponentInChildren <Cultist>();

            if (!tileCultist)
            {
                if (mana >= taskmasterCost + cultistCost)
                {
                    DeltaMana(-(taskmasterCost + cultistCost));
                }
                else
                {
                    NotEnoughMana();
                    return;
                }
                tileCultist = SpawnCultist(tile);
                tileCultist.UpdateLeader(Cultist.LeaderState.taskmaster);
                PlayCastClip();
            }
            else if (tileCultist.curLeaderState != Cultist.LeaderState.taskmaster)
            {
                if (mana >= taskmasterCost)
                {
                    DeltaMana(-taskmasterCost);
                }
                else
                {
                    NotEnoughMana();
                    return;
                }
                tileCultist.UpdateLeader(Cultist.LeaderState.taskmaster);
                PlayCastClip();
            }
            else
            {
                tileCultist.UpdateLeader(Cultist.LeaderState.taskmaster);
            }
        }
        else if (curUserState == UserStates.necromancer)
        {
            Cultist tileCultist = tile.GetComponentInChildren <Cultist>();

            if (!tileCultist)
            {
                if (mana >= necroCost + cultistCost)
                {
                    DeltaMana(-(necroCost + cultistCost));
                }
                else
                {
                    NotEnoughMana();
                    return;
                }
                tileCultist = SpawnCultist(tile);
                tileCultist.UpdateLeader(Cultist.LeaderState.necromancer);
                PlayCastClip();
            }
            else if (tileCultist.curLeaderState != Cultist.LeaderState.necromancer)
            {
                if (mana >= necroCost)
                {
                    DeltaMana(-necroCost);
                }
                else
                {
                    NotEnoughMana();
                    return;
                }
                tileCultist.UpdateLeader(Cultist.LeaderState.necromancer);
                PlayCastClip();
            }
        }
        else if (curUserState == UserStates.succubus)
        {
            if (mana >= necroCost)
            {
                DeltaMana(-necroCost);
            }
            else
            {
                NotEnoughMana();
                return;
            }
            Succubus tileSuccubus = tile.CreateUnit <Succubus>(succubus);
            PlayCastClip();
        }
        else if (curUserState == UserStates.ghost)
        {
            if (mana >= ghostCost)
            {
                DeltaMana(-ghostCost);
            }
            else
            {
                NotEnoughMana();
                return;
            }
            Ghost tileGhost = tile.CreateUnit <Ghost>(ghost);
            PlayCastClip();
        }
    }
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("").GetComponent<Succubus>();
 }
예제 #3
0
    protected override void UnitUpdate()
    {
        //Do your stuff here


        //First combat (part of move timer?)
        Tile tile = GetComponentInParent <Tile>();

        if (terrified)
        {
            if (this.hometile.coord == tile.coord)
            {
                terrified = false;
            }
            else
            {
                MoveUnit(this.hometile.coord - tile.coord);
            }
            return;
        }

        GridManager grid    = this.transform.root.GetComponent <GridManager>();
        Cultist     cultist = tile.GetComponentInChildren <Cultist>();
        Zombie      zombie  = tile.GetComponentInChildren <Zombie>();
        Victim      victim  = tile.GetComponentInChildren <Victim>();

        if (cultist != null)
        {
            Debug.Log("MORTAL COMMBAAAAT C");
            //MORTAL COMBAAAAT
            cultist.LoseHealth(1);
            LoseHealth(1);
        }
        else if (zombie != null)
        {
            Debug.Log("MORTAL COMMBAAAAT Z");
            //MORTAL COMBAAAAT
            zombie.LoseHealth(1);
            LoseHealth(1);
        }
        else if (victim != null)
        {
            //Free the victims from their oppressors!
            victim.LoseHealth(1);
        }
        else
        {
            //No combat or victims to save.
            //First:  Think with your pants.
            Succubus foundSuccubus = LocateClosestGridEntity <Succubus>(1);
            if (foundSuccubus != null)
            {
                //Hey there cute stuff
                MoveUnit(foundSuccubus.GetComponentInParent <Tile>().coord - tile.coord);
            }
            else if (grid.IsValidTile(enemyLocation))
            {
                //Check if we have an alert
                if (enemyLocation == tile.coord)
                {
                    //Set it to null, we got to the point.
                    enemyLocation.Set(-1, -1);
                }
                else
                {
                    MoveUnit(enemyLocation - tile.coord);
                }
            }
            else
            {
                Cultist foundCultist = LocateClosestGridEntity <Cultist>(1);
                if (foundCultist != null)
                {
                    //WE FOUND A CULTIST, F**K EM UP
                    Debug.Log("FOUND A CULTIST, GET EM");
                    MoveUnit(foundCultist.GetComponentInParent <Tile>().coord - tile.coord);
                }
                else if (!(tile is Castle))
                {
                    //We arn't on a castle, and there is nothing else to do.

                    //Go home
                    MoveUnit(this.hometile.coord - tile.coord);
                }
            }
        }
    }