Ejemplo n.º 1
0
    public void GetTargetFromAttackButton()
    {
        {
            MapCoordinate[,] map = MapDataController.map;
            Vector2Int orgPos = pcon.GetPos();
            float      range  = pcon.pinfo.stats.range;

            for (int i = 1; i <= range; i++)
            {
                Vector2Int targetPos = TargetPosition(orgPos.x, orgPos.y, i);
                PlayerInfo targetNpc = map[targetPos.x, targetPos.y].GetNpc();
                if (targetNpc != null)
                {
                    int targetTeam = targetNpc.GetTeam();
                    int team       = pcon.pinfo.GetTeam();

                    if (targetTeam != team)
                    {
                        GameObject         enemy   = targetNpc.hpCon.gameObject.transform.parent.gameObject;
                        EnemyControllerNew ec      = enemy.GetComponent <EnemyControllerNew>();
                        SpriteRenderer     markBox = ec.GetMarkBox();
                        Target.SetTargetUnit(targetNpc, markBox);

                        gi.SetDmgTextColor(1);
                        gi.dmg = pcon.pinfo.stats.GetRandomDamage();
                        AttackTarget(targetNpc);
                    }
                }
            }
        }
    }
    IEnumerator SpawnEnemy()
    {
        float spawnDelay     = 1;
        float tileFlashSpeed = 4;

        Transform spawningTile = map.GetRandomOpenTile();

        if (isCamping)
        {
            spawningTile = map.GetTileFromPosition(playerT.position);
        }

        Material tileMat      = spawningTile.GetComponent <Renderer>().material;
        Color    initialColor = tileMat.color;
        Color    flashColor   = Color.red;
        float    spawnTimer   = 0;

        while (spawnTimer < spawnDelay)
        {
            tileMat.color = Color.Lerp(initialColor, flashColor, Mathf.PingPong(spawnTimer * tileFlashSpeed, 1));

            spawnTimer += Time.deltaTime;
            yield return(null);
        }

        EnemyControllerNew spawnedEnemy = Instantiate(enemy, spawningTile.position + Vector3.up, Quaternion.identity) as EnemyControllerNew;

        spawnedEnemy.OnDeath += OnEnemyDeath;
        spawnedEnemy.SetCharacteristics(currentWave.moveSpeed, currentWave.hitsToKillPlayer, currentWave.enemyHealth);

        if (tileMat.color != initialColor)
        {
            tileMat.color = initialColor;
        }
    }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        anim      = gameObject.transform.GetChild(0).GetComponent <AnimationManager>();
        ec        = GetComponent <EnemyControllerNew>();
        plrChar   = gameObject.transform.GetChild(0).gameObject;
        waitTimer = new TimerEC(0.75f);
        UpdatePosAsInt();

        totalSearch = 0;
        MapDataController.map[pos.x, pos.y].SetNpc(ec.pinfo);
    }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     assetsLib = GameObject.FindGameObjectWithTag("Assets").GetComponent <AssetsLibrary>();
     markBox   = gameObject.transform.GetChild(2).gameObject.GetComponent <SpriteRenderer>();
     trav      = GetComponent <TravelerController>();
     hpcon     = gameObject.transform.GetChild(1).gameObject.GetComponent <HealthbarController>();
     pinfo     = new PlayerInfo(2, hpcon);
     ec        = gameObject.GetComponent <EnemyControllerNew>();
     attTimer  = ec.pinfo.stats.attackCooldown;
     gi.ec.Add(ec);
 }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        spawner = GameObject.Find("Assets").GetComponent <Spawner>();
        plr     = gameObject.transform.parent.gameObject;
        assets  = GameObject.Find("Assets").GetComponent <AssetsLibrary>();
        if (plr.name == "Player")
        {
            pcon = gameObject.transform.parent.GetComponent <PlayerController>();
        }
        else if (plr.name != "Player")
        {
            ec = gameObject.transform.parent.GetComponent <EnemyControllerNew>();
        }

        spRe = gameObject.GetComponent <SpriteRenderer>();
    }
Ejemplo n.º 6
0
 public void RemoveEC(EnemyControllerNew i)
 {
     gi.ec.Remove(i);
     CheckEC();
     //Debug.Log(gi.ec.Count);
 }