Exemple #1
0
    //private float retreatDistance = minimalDistance; //Дистанция отступления

    //public GameObject deathEffect;

    void Start()
    {
        rb = GetComponent <Rigidbody2D>();
        _animatorController = GetComponent <Animator>();

        myNewPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z); //myStartPosition (myStartPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z));
        target        = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
        maxHealth     = health;
        movementSpeed = startMovementSpeed;

        if (spellSummon != null || spell_1 != null || spell_2 != null)
        {
            specialEffect = GetComponent <SpecialEffect>();
        }
        AILerp      = this.GetComponent <Pathfinding.AILerp>();
        Seeker      = this.GetComponent <Pathfinding.Seeker>();
        EnemyAIDest = this.GetComponent <Pathfinding.EnemyAIDest>();

        elementsAndEffects = this.GetComponent <ElementsAndEffects>();
        //Для WalkingAndWander
        //waitTime = startWaitTime;
        //minX = transform.position.x - walkingRange;
        //maxX = transform.position.x + walkingRange;
        //minY = transform.position.y - walkingRange;
        //maxY = transform.position.y + walkingRange;
    }
Exemple #2
0
    // Use this for initialization
    void Awake()
    {
        destSetter      = GetComponent <Pathfinding.AIDestinationSetter>();
        destLerp        = GetComponent <Pathfinding.AILerp>();
        player          = GameObject.Find("Player");
        curseController = GameObject.Find("CurseController").GetComponent <CurseController>();

        enemyTransform   = GetComponent <Transform>();
        enemyBoxCollider = GetComponent <BoxCollider2D>();
        stats            = GetComponent <ObjectStats>();
        moveScript       = GetComponent <MoveObject>();
        moveConf         = GetComponent <MoveConfirmation>();

        gameCamera = GameObject.Find("Main Camera").GetComponent <CameraController>();

        enemyHealthBar     = this.transform.Find("ObjectCanvas").transform.Find("EnemyHealthBar").gameObject.GetComponent <RectTransform>();
        enemyCanvas        = this.transform.Find("ObjectCanvas").gameObject;
        healthBarMaxWidth  = enemyHealthBar.rect.width;
        healthBarCurrWidth = healthBarMaxWidth;

        spriteRender = GetComponent <SpriteRenderer>();

        stunned = false;


        InitializeValues();

        destSetter.target = player.transform;

        wallLayer = 8;
    }
Exemple #3
0
 void Start()
 {
     lerp          = GetComponent <AILerp>();
     findMe        = GetComponent <AIDestinationSetter>();
     state         = DogState.DEFAULT;
     player        = GameObject.FindGameObjectWithTag("Player");
     findMe.target = player.transform;
 }
Exemple #4
0
    void Damage(Transform enemy)
    {
        Enemy e             = enemy.GetComponent <Enemy>();
        int   currentDamage = this.damage;

        if (this.towerName == "fire")
        {
            // more damage on soldier
            if (e.enemyName == "soldier")
            {
                currentDamage += (int)(this.damage * 0.2);
            }
        }
        else if (this.towerName == "wind")
        {
            // nothing happens
        }
        else if (this.towerName == "earth")
        {
            if (e.enemyName == "soldier")
            {
                currentDamage -= (int)(this.damage * 0.5);
                Pathfinding.AILerp temp = e.GetComponentsInParent <Pathfinding.AILerp> ()[0];
                temp.speed = temp.speed / 2 + 20;
            }
        }
        else if (this.towerName == "water")
        {
            if (e.enemyName == "tank" || e.enemyName == "helicopter")
            {
                currentDamage -= (int)(this.damage * 0.5);
                Pathfinding.AILerp temp = e.GetComponentsInParent <Pathfinding.AILerp> ()[0];
                temp.speed = temp.speed / 2 + 20;
            }
        }
        else if (this.towerName == "lightning")
        {
            if (e.enemyName == "helicopter")
            {
                currentDamage += (int)(this.damage * 0.2);
            }
        }

        if (e != null)
        {
            // apply variable formulas
            e.TakeDamage(currentDamage);
        }
    }
 private void Start()
 {
     lerp = GetComponent <AILerp>();
 }