Esempio n. 1
0
    // Use this for initialization
    public virtual void Awake()
    {
        sndsource = GetComponent <AudioSource>();
        bonus     = 0;
        //adjacency = 1;
        doresistcalc     = true;
        dieAfterMove     = false;
        damagesources    = new List <Vector3>();
        damageresistance = 0;
        unitCanvas       = GetComponentInChildren <UnitCanvas>();
        animating        = false;
        Morale           = MaxMorale;

        unitCanvas.SetMaxMP(MaxMorale);
        unitCanvas.SetCurrentMP(MaxMorale);

        actions     = new List <Action>();
        movesLeft   = movesPerTurn;
        currentVect = Vector3.zero;
        rb          = GetComponent <Rigidbody2D>();
        steps       = new List <Vector3Int>();
        //position = Vector3Int.RoundToInt(transform.position - offset);
        gridController = transform.parent.gameObject.GetComponent <TileGridController>();
        //gridController.blockPosition()
        actions.Add(new Action("Move", MoveDistance, ActType.Movement, 0, -1, "", "", Color.white));
        actions.Add(new Action("Blow vuvuzela", 6, ActType.Cone, 6, 6, "EnemyUnit", "DOOT!", Color.white, 0, 4));
        actions.Add(new Action("Finger guns", 9, ActType.Targetted, 6, 0, "Unit", "Finger guns", Color.white, 0, 1));
        actions.Add(new Action("Glitterbomb", 6, ActType.Grenade, 10, 10, "", "Glitterbomb", Color.white, 0, 6));
        //actions.Add(new Action("Strike a pose", 0, ActType.Grenade, 10, 20));
        actions.Add(new Action("Bear hug", MoveDistance, ActType.Melee, 6, -1, "", "Bear hug", Color.cyan, 0, 0));
    }
Esempio n. 2
0
    public void Damage(int dmg, Vector3 source, string tg = "")
    {
        if (Morale <= 0)
        {
            return;
        }
        if (gameObject.tag == tg)
        {
            dmg *= -1;
            //Morale -= dmg;
        }
        if (dmg > 0)
        {
            if (!float.IsInfinity(source[0]))
            {
                damagesources.Add(source - transform.position);
            }
            CalcResistance();
            dmg = Mathf.Max(1, dmg - damageresistance);
        }
        Morale -= dmg;
        if (Morale > MaxMorale)
        {
            Morale = MaxMorale;
        }
        unitCanvas.SetCurrentMP(Morale);
        StartCoroutine(unitCanvas.DamageAnimation(-dmg));
        if (Morale <= 0)
        {
            movesPerTurn = 0;
            movesLeft    = 0;
            gridController.RemoveEntity(gameObject);
            GameObject newflag = Instantiate(whiteFlagPrefab, transform, false);
            newflag.transform.localPosition = handlocation;
            gridController.getPath(Vector3Int.FloorToInt(transform.position),
                                   Vector3Int.one, steps, 200, true);
            dieAfterMove = true;

            /*if (tag == "EnemyUnit")
             * {
             *  gridController.defeatedfoes++;
             * }*/
            //Destroy(gameObject);
        }
    }