Beispiel #1
0
 public void RemoveEnemy(EnemyID newEnemy)
 {
     if (Enemies.Contains(newEnemy))
     {
         Enemies.Remove(newEnemy);
     }
 }
 public EnemyClass()
 {
     CurrentPosition = Vector2.zero;
     Grid            = null;
     myID            = new EnemyID();
     LM = null;
 }
Beispiel #3
0
    // instanciate the round settings
    public RoundSettings(MovementID _moveID = MovementID.walk, EnemyID _enemyID = EnemyID.none, CombatID _combatID = CombatID.none, TerrainID _terrainID = TerrainID.open)
    {
        moveID    = _moveID;
        enemyID   = _enemyID;
        combatID  = _combatID;
        terrainID = _terrainID;

        moveInfo = MovementSettings.GetMovement(moveID);
    }
Beispiel #4
0
    public float getID(int id)
    {
        EnemyID ID = null;

        list.TryGetValue(id, out ID);
        if (ID == null)
        {
            return(0);
        }
        if (ID.Tag == null)
        {
            return(0);
        }
        return(ID.Tag.getID());
    }
        public static CharacterModel CreateEnemyData(EnemyID id)
        {
            var model = new CharacterModel();

            model.Identifier = id;
            model.TargetTag  = "Player";
            model.PrefabName = "Character";

            model.MaxHealth = 1;
            model.ResetHealth();

            model.IsPlayable = false;

            return(model);
        }
Beispiel #6
0
    public static Enemy CreateEnemy(EnemyID id)
    {
        // switch statment creates the right type of enemy based on the combat ID
        switch (id)
        {
        case EnemyID.none:
            Debug.LogWarning("none enemy ID should never call Create Enemy, null returned");
            return(null);

        case EnemyID.simpleFollower:
            GameObject go = new GameObject();
            return(go.AddComponent <SimpleFollower>());

        default:
            Debug.LogWarning("non supported enemy ID called to Create Enemy, null retunred");
            return(null);
        }
    }
Beispiel #7
0
    public GameObject GetEnemy(EnemyID enemyID)
    {
        GameObject        e;
        int               eID          = (int)enemyID;
        List <GameObject> enemySubPool = enemyPool[eID];

        if (enemySubPool.Count > 0)
        {
            e = enemySubPool[enemySubPool.Count - 1];
            enemySubPool.RemoveAt(enemySubPool.Count - 1);
        }

        else
        {
            enemySubPool.Capacity++;
            e = Instantiate(enemyPrefabs[eID]);
            e.SetActive(false);
        }

        enemyActiveCounts[eID]++;
        e.GetComponent <Enemy>().Activate();
        return(e);
    }
Beispiel #8
0
    void SpawnNewEnemy()
    {
        EnemyID spawnID = EnemyID.Blue; // default
        int     rng     = Random.Range(0, 100);

        if (rng < spawnProbabilityDict[EnemyID.Blue])
        {
            spawnID = EnemyID.Blue;
        }
        else if (rng < spawnProbabilityDict[EnemyID.Green])
        {
            spawnID = EnemyID.Red;
        }
        else if (rng < spawnProbabilityDict[EnemyID.Red])
        {
            spawnID = EnemyID.Green;
        }
        else
        {
            spawnID = EnemyID.UFO;
        }

        ObjectPool.Instance.GetEnemy(spawnID);
    }
Beispiel #9
0
    internal void EnemyType(EnemyID id) //sets id passed statistics
    {
        CurrentEnemyID = id;
        switch (CurrentEnemyID)
        {
        case EnemyID.Teleport:
            ReAssignTypeVal(Color.white, id.ToString(), 15, 5, enemyvalue: 20);
            break;

        case EnemyID.Phasing:
            ReAssignTypeVal(Color.black, id.ToString(), maxhp: 4, enemyvalue: 15);
            gameObject.GetComponent <Renderer>().material = (Material)(Resources.Load("Box'o'Baddies/FragmentMat"));
            break;

        case EnemyID.Boss:
            ReAssignTypeVal(Color.red, id.ToString(), enemyvalue: 250, armourvalue: 3, scalar: 25);
            break;

        case EnemyID.Assasin:
            ReAssignTypeVal(Color.yellow, id.ToString(), 20, 5, 20, scalar: 6);
            break;

        case EnemyID.Knight:
            ReAssignTypeVal(Color.grey, id.ToString(), 10, 8, 30, 1.5f, 12);
            break;

        case EnemyID.Support:
            ReAssignTypeVal(Color.clear, id.ToString(), 11, 8, 10, 0);
            break;

        case EnemyID.Mother:
            ReAssignTypeVal(new Color32(255, 181, 197, 255), id.ToString(), 11, 15);
            break;

        case EnemyID.Shielded:
            ReAssignTypeVal(new Color32(0, 0, 128, 255), id.ToString(), 9, 5, 9);
            break;

        case EnemyID.Charger:
            ReAssignTypeVal(new Color32(0, 255, 255, 255), id.ToString(), 50);
            break;

        case EnemyID.Regenerator:
            ReAssignTypeVal(new Color32(0, 128, 0, 255), id.ToString(), enemyvalue: 45);
            break;

        case EnemyID.Undead:
            ReAssignTypeVal(new Color32(65, 90, 190, 255), id.ToString(), enemyvalue: 10);
            break;

        case EnemyID.Bonus:
            ReAssignTypeVal(Color.black, id.ToString(), 100, 2, 200, 1, 8);
            GameObject BonusParent = new GameObject(gameObject.name);
            BonusParent.gameObject.transform.SetParent(transform.parent);
            transform.SetParent(BonusParent.transform);
            break;

        case EnemyID.Child:
            if (UnityEngine.Random.value > .5f)
            {
                ReAssignTypeVal(new Color32(135, 206, 255, 0), id.ToString(), 7, 5, 2, 0.5f, 4);
            }
            else
            {
                ReAssignTypeVal(new Color32(255, 105, 180, 0), id.ToString(), 10, 4, 1, 0.5f, 4);
            }
            break;

        default:
            ReAssignTypeVal(new Color32(65, 90, 190, 255));
            break;
        }
    }
Beispiel #10
0
    void Update() //Update is called once per frame
    {
        if (FinalPath.Count > 0)
        {
            foreach (var item in FinalPath)
            {
                Debug.DrawLine(item.transform.position + GetExtents(item), transform.position, Color.red, 2);
            }
        }
        switch (CurrentEnemyID) //unique functions per enemy type
        {
        case EnemyID.Bonus:
            transform.Rotate(Vector3.right * UnityEngine.Random.value * 5);
            gameObject.GetComponent <Renderer>().material.color = Color.Lerp(Color.yellow, Color.black, Mathf.PingPong(Time.time, 1));    //Color pulsing
            StandardMovement();
            break;

        case EnemyID.Charger:
            StandardMovement();
            break;

        case EnemyID.Regenerator:
            gameObject.GetComponent <Renderer>().material.color = Color.Lerp(new Color32(250, 128, 114, 255), new Color32(0, 128, 0, 255), Mathf.PingPong(Time.time, 1.5f));
            StandardMovement();
            break;

        case EnemyID.Phasing:
            Color col = GetComponent <Renderer>().material.color;
            GetComponent <Renderer>().material.color = new Color(col.r, col.g, col.b, Mathf.PingPong(Time.time / 4, 1));
            StandardMovement();
            break;

        case EnemyID.Support:
            if (GameObject.Find("EnemyController").transform.childCount > 2)
            {
                float tempDist = 999999;
                foreach (Transform enemy in GameObject.Find("EnemyController").transform)
                {
                    if (enemy.name != "FragmentEncapsulation" && enemy.name != "Support" && Vector3.Distance(gameObject.transform.position, enemy.position) <= tempDist && enemy.GetComponent <EnemyFunction>().CurrentHP + 2 <= enemy.GetComponent <EnemyFunction>().MaxHP)
                    {
                        tempDist = Vector3.Distance(gameObject.transform.position, enemy.position);
                        Ally     = enemy.gameObject;
                    }
                }
            }
            else
            {
                Ally = gameObject;
            }
            if (Ally = gameObject)
            {
                StandardMovement();
            }
            else
            {
                GetComponent <Rigidbody>().velocity = ((Ally.transform.position - Vector3.back) - transform.position).normalized * MoveSpeed;
            }
            break;

        case EnemyID.Resurrecting:
            Collider GOCollider = GetComponent <Collider>();
            GOCollider.enabled            = false;
            gameObject.transform.position = new Vector3(ResPos.x, Mathf.Lerp((ResPos + (Vector3.down * 30)).y, ResPos.y, Time.time / 20), ResPos.z);
            if (gameObject.transform.position.y >= ResPos.y)
            {
                CurrentEnemyID     = EnemyID.Default;
                GOCollider.enabled = true;
                gameObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY;
            }
            break;

        default:
            StandardMovement();
            break;
        }
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit; //Ray stuff for damage text popups
            if ((Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)))
            {
                if (hit.transform == transform) //Is the ray hitting this transform?
                {
                    if (UnityEngine.Random.Range(0, 20) <= 1)
                    {
                        AudioSource.PlayClipAtPoint(DamageSound, maincamera.transform.position, 0.03f);
                    }
                    DamageDealt = GameManagerStuff.Damage;
                    CurrentHP  += (DamageDealt / ArmourVal) * GameManagerStuff.ArmourPiercingPC;
                    GameManager.DisplayValue((DamageDealt / ArmourVal) * GameManagerStuff.ArmourPiercingPC, gameObject.transform.position);
                    GameManager.FragmentEnemy(gameObject, 1, 1);
                    GameManagerStuff.Currency += GameManagerStuff.Bonus;
                    if (CurrentEnemyID == EnemyID.Teleport)
                    {
                        Teleport(gameObject);
                    }
                }
            }
        }
        if (CurrentHP <= 0)
        {
            AudioSource.PlayClipAtPoint(DeathSound, maincamera.transform.position, 0.03f);
            if (CurrentEnemyID == EnemyID.Mother)
            {
                ESp.SpawnBaddie(EnemyID.Child, transform.position + Vector3.right * 5);
                ESp.SpawnBaddie(EnemyID.Child, transform.position + Vector3.left * 5);
                Destroy(killzonepathing);
                Destroy(gameObject);
            }
            else if (CurrentEnemyID == EnemyID.Undead)
            {
                ResPos         = gameObject.transform.position;
                CurrentHP      = MaxHP;
                CurrentEnemyID = EnemyID.Resurrecting;
                gameObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
                GetComponent <Renderer>().material.color          = new Color32(152, 251, 152, 255);
                GameManager.FragmentEnemy(gameObject, 10, 15);
            }
            else
            {
                GameManager.FragmentEnemy(gameObject, 10, 15);
                GameManagerStuff.EnemiesKilled++;
                Destroy(killzonepathing);
                Destroy(gameObject);
            }
            GameManagerStuff.Currency += EnemyValue;
        }
    }
Beispiel #11
0
    void GridCreation()
    {
        int i  = 0;
        int ID = 0;

        Grid = new GameObject[GridXHeight, GridZHeight];
        LM.SetEnemeies();
        for (int x = 0; x < GridXHeight; x += 1)
        {
            for (int z = 0; z < GridZHeight; z += 1)
            {
                int currentPiece = int.Parse(Level[x].Substring(z, 1));
                if (Level[x].Substring(z, 1) != "0")
                {
                    i++;
                    Grid[x, z] = Instantiate(block1);
                    Grid[x, z].transform.position = new Vector3(this.transform.position.x + x /*- (0.02f * x)*/, this.transform.position.y, this.transform.position.z + z /*- (0.02f * z)*/);
                    Grid[x, z].transform.parent   = transform.gameObject.transform;
                    Grid[x, z].name = x.ToString("00") + z.ToString("00");
                }

                else
                {
                    Grid[x, z] = null;
                }

                if (Level[x].Substring(z, 1) == "2")
                {
                    var temp = Instantiate(Columns, new Vector3(Grid[x, z].transform.position.x, Grid[x, z].transform.position.y + +(Grid[x, z].transform.lossyScale.y / 2), Grid[x, z].transform.position.z), Quaternion.identity);
                    temp.name             = "Column";
                    temp.transform.parent = transform;
                    Grid[x, z].GetComponent <GridSquare>().SetAbove(true);
                }


                if (currentPiece >= 4 && currentPiece < 8)
                {
                    var temp = Instantiate(Walker, new Vector3(Grid[x, z].transform.position.x, Grid[x, z].transform.position.y + (Grid[x, z].transform.lossyScale.y / 2), Grid[x, z].transform.position.z), Quaternion.identity);
                    temp.name             = "Walker";
                    temp.transform.parent = transform;
                    int currentDir = currentPiece - 4;
                    switch (currentDir)
                    {
                    case 0: temp.GetComponent <PathWalkerAI>().currentDir = new Vector2(1, 0); break;

                    case 1: temp.GetComponent <PathWalkerAI>().currentDir = new Vector2(-1, 0); break;

                    case 2: temp.GetComponent <PathWalkerAI>().currentDir = new Vector2(0, 1); break;

                    case 3: temp.GetComponent <PathWalkerAI>().currentDir = new Vector2(0, -1); break;
                    }
                    IEnemy enemy = (IEnemy)temp.GetComponent(typeof(IEnemy));
                    enemy.SetPos(new Vector2(x, z));
                    enemy.SetRotation(currentDir);
                    enemy.SetLM(GetComponent <LevelManager>());
                    if (temp.GetComponent <PathFinding>() != null)
                    {
                        temp.GetComponent <PathFinding>().CurrentGridPosition = new Vector2(x, z);
                    }

                    Grid[x, z].GetComponent <GridSquare>().SetAbove(true);
                    EnemyID newID = new EnemyID(ID, temp);
                    enemy.SetID(newID);
                    LM.AddEnemy(newID);
                    ID++;
                }


                if (currentPiece >= 8 && currentPiece < 12)
                {
                    var temp = Instantiate(Turret, new Vector3(Grid[x, z].transform.position.x, Grid[x, z].transform.position.y + (Grid[x, z].transform.lossyScale.y / 2), Grid[x, z].transform.position.z), Quaternion.identity);
                    temp.name             = "Turret";
                    temp.transform.parent = transform;
                    int currentDir = currentPiece - 4;

                    IEnemy enemy = (IEnemy)temp.GetComponent(typeof(IEnemy));
                    enemy.SetPos(new Vector2(x, z));
                    enemy.SetRotation(currentDir);
                    enemy.SetLM(GetComponent <LevelManager>());
                    if (temp.GetComponent <PathFinding>() != null)
                    {
                        temp.GetComponent <PathFinding>().CurrentGridPosition = new Vector2(x, z);
                    }

                    Grid[x, z].GetComponent <GridSquare>().SetAbove(true);
                    EnemyID newID = new EnemyID(ID, temp);
                    enemy.SetID(newID);
                    LM.AddEnemy(newID);
                    ID++;
                }

                if (currentPiece >= 12 && currentPiece < 16)
                {
                    var temp = Instantiate(Sniper, new Vector3(Grid[x, z].transform.position.x, Grid[x, z].transform.position.y + (Grid[x, z].transform.lossyScale.y / 2), Grid[x, z].transform.position.z), Quaternion.identity);
                    temp.name             = "Sniper";
                    temp.transform.parent = transform;
                    int currentDir = currentPiece - 4;

                    IEnemy enemy = (IEnemy)temp.GetComponent(typeof(IEnemy));
                    enemy.SetPos(new Vector2(x, z));
                    enemy.SetRotation(currentDir);
                    enemy.SetLM(GetComponent <LevelManager>());
                    if (temp.GetComponent <PathFinding>() != null)
                    {
                        temp.GetComponent <PathFinding>().CurrentGridPosition = new Vector2(x, z);
                    }

                    Grid[x, z].GetComponent <GridSquare>().SetAbove(true);
                    EnemyID newID = new EnemyID(ID, temp);
                    enemy.SetID(newID);
                    LM.AddEnemy(newID);
                    ID++;
                }
                if (Level[x].Substring(z, 1) == "3")
                {
                    var temp = Instantiate(Player, new Vector3(Grid[x, z].transform.position.x, Grid[x, z].transform.position.y + 1, Grid[x, z].transform.position.z), Quaternion.identity);
                    temp.name             = "Player";
                    temp.transform.parent = transform;
                    PlayerMovement player = temp.GetComponent <PlayerMovement>();
                    player.CurrentSquare = new Vector2(x, z);
                    Grid[x, z].GetComponent <GridSquare>().SetAbove(true);
                    LM.setPlayer(temp);
                }
            }
        }
        SetDestination();
    }
        private void Instantiate(EnemyID id, Transform parent, Action <CharacterController> onCreateSuccess)
        {
            var model = CharacterModel.CreateEnemyData(id);

            CharacterController.Create(model, parent, transform.localPosition, onCreateSuccess.SafeCall);
        }
Beispiel #13
0
 public void SetID(EnemyID id)
 {
     CurrentEnemy.SetID(id);
 }
Beispiel #14
0
 public EnemyModel GetEnemyModelByID(EnemyID id)
 {
     return(EnemyModels.Find(enemyModel => enemyModel.ID == id));
 }
Beispiel #15
0
    //deprecated
    public EnemyData GetEnemy(EnemyID enemyId)
    {
        EnemyAssetData result = enemies.TryGetValue(enemyId.Name);

        return(result != null?result.GenerateBasic() : null);
    }
Beispiel #16
0
 public void SetID(EnemyID id)
 {
     CurrentEnemy.SetID(id);
     actionFinished = false;
 }
Beispiel #17
0
 public DeadGuyToRespawn(Vector3 pos, EnemyID id, AggroGroup g, float delay)
 {
     iidd      = id;
     groupWith = g;
     spawnHere = pos;
 }
Beispiel #18
0
    // Update is called once per frame
    void Update()
    {
        if (TimerShoot >= 0.0f)
        {
            TimerShoot -= Time.deltaTime;
        }

        if ((Input.GetButtonDown("Fire1") || Input.GetButtonDown("Fire2") || Input.GetButtonDown("Fire3") || Input.GetButtonDown("Fire4")) && TimerShoot <= 0.0f)
        {
            ApplyState();
            TimerShoot = CDShoot;
            if (EnemyOnRange.Count == 0)
            {
                scoreManager.MissEnemy();
                Debug.Log("No enemy on range");
            }
            else
            {
                //First enemy in the array would be the closest
                float Closestdistance = 999999;
                int   Closesti        = 0;

                for (int i = 0; i < EnemyOnRange.Count; i++)
                {
                    GameObject temp = null;
                    if ((GameObject)EnemyOnRange[i] != null)
                    {
                        temp = (GameObject)EnemyOnRange[i];
                    }
                    if (temp != null)
                    {
                        float dist = Vector3.Distance(gameObject.transform.position, temp.gameObject.transform.position);
                        if (dist < Closestdistance)
                        {
                            Closesti        = i;
                            Closestdistance = dist;
                        }
                    }
                }
                if (Closestdistance != 999999)
                {
                    GameObject enemy   = (GameObject)EnemyOnRange[Closesti];
                    EnemyID    enemyID = enemy.GetComponent <EnemyID>();



                    if (Input.GetButtonDown(enemyID.input))
                    {
                        //bon input
                        enemy.GetComponent <SimpleMoveEnemy>().DestroyedByPlayer();
                        // Debug.Log("Enemy hit");
                        EnemyOnRange.RemoveAt(0);
                    }
                    else
                    {
                        enemy.GetComponent <SimpleMoveEnemy>().DestroyByBadinput();
                        //  Debug.Log("Wrong input");
                        EnemyOnRange.RemoveAt(0);
                        ScoreManager.landedHit++;
                        //mauvaise input
                    }
                    Closesti        = 0;
                    Closestdistance = 999999;
                }
            }
        }
    }
 public void SetID(EnemyID id)
 {
     myID = id;
 }
Beispiel #20
0
 public static IDungeonCharacter GetCharacter(EnemyID id)
 {
     return(null);
 }
Beispiel #21
0
 public void AddEnemy(EnemyID newEnemy)
 {
     Enemies.Add(newEnemy);
 }