示例#1
0
    public override void Hit(Unit_ unit)
    {
        base.Hit(unit);
        UnitBehaviour_ unitBehaviour_ = (UnitBehaviour_)unit.mechanics_.behaviour_;

        unitBehaviour_.attackTarget = owner.gameObject;
    }
    public void Decide()
    {
        foreach (Base_ baseObject in visualPerception_.baseObjectsInVisualField)
        {
            switch (baseObject.baseType_)
            {
            case BaseType_.Item:
                break;

            case BaseType_.Unit:
                Unit_ unit = ((Unit_)baseObject);
                if (IsEnemy(unit) && stats_.hp >= 0)    //Si es mi enemigo, si aún está vivo y si aún yo estoy vivo...
                {
                    if (((UnitStats_)unit.mechanics_.stats_).hp >= 0)
                    {
                        attackTarget = unit.gameObject;
                    }
                    else
                    {
                        attackTarget = null;
                    }
                }
                break;

            case BaseType_.Tree:
                break;

            default:
                break;
            }
        }
    }
    public void HitAttackTarget()
    {
        Unit_          unit          = (Unit_)owner;
        UnitBehaviour_ unitBehaviour = (UnitBehaviour_)unit.mechanics_.behaviour_;

        unitBehaviour.HitAttackTarget();
    }
 private void RemoveFromCurrentlySelectedUnits(Unit_ unitToRemove)
 {
     if (selectedUnits.Count > 0)
     {
         unitToRemove.transform.Find("SelectionCircle").gameObject.SetActive(false);
         selectedUnits.Remove(unitToRemove);
     }
 }
 private void AddToCurrentlySelectedUnits(Unit_ unitToAdd)
 {
     if (!selectedUnits.Contains(unitToAdd))
     {
         selectedUnits.Add(unitToAdd);
         unitToAdd.transform.Find("SelectionCircle").gameObject.SetActive(true);
     }
 }
示例#6
0
 public int GetRelationShipLevel(Unit_ unit)
 {
     if (this.diplomacy == ((UnitStats_)unit.mechanics_.stats_).diplomacy)
     {
         return(1);
     }
     else
     {
         return(-1);
     }
 }
    public bool IsEnemy(Unit_ unit)
    {
        bool         isEnemy = false;
        Relationship rs      = stats_.relationships.Find(t => t.unit == unit);

        if (rs.level < 0)
        {
            isEnemy = true;
        }
        return(isEnemy);
    }
示例#8
0
    public virtual void Hit(Unit_ unit)
    {
        UnitStats_ unitStats = (UnitStats_)unit.mechanics_.stats_;

        unitStats.hp -= stats_.GetHitDamage() / 2;
        unit.graphics_.inGame_.animator.SetFloat("hp", unitStats.hp);
        ((UnitBehaviour_)unit.mechanics_.behaviour_).GetEquippedItemAnimators().ForEach(t => t.SetFloat("hp", unitStats.hp));
        if (unit.GetType() == typeof(Player_))
        {
            PlayerBottomUiMiddleContainer_ playerBottomUiMiddleContainer_ = (PlayerBottomUiMiddleContainer_)unit.graphics_.ui.bottomUI.GetComponent <PlayerBottomUi_>().playerBottomUiMiddleContainer_;
            playerBottomUiMiddleContainer_.healthBarContainer.slider.value = unitStats.hp;
        }
        else if (unit.GetType() == typeof(Npc_))
        {
            NpcBottomUiLeftContainer_ npcBottomUiLeftContainer_ = (NpcBottomUiLeftContainer_)unit.graphics_.ui.bottomUI.GetComponent <NpcBottomUi_>().leftContainer_;
            npcBottomUiLeftContainer_.barContainers.hpBar.value = unitStats.hp;
        }
    }
示例#9
0
 public void Attack(Unit_ unit)
 {
     if (stats_.hp >= 0)
     {
         attackTarget = unit.gameObject;
         if (WorldController_.DistanceBetween(owner.transform.position, unit.transform.position) < 0.5)
         {
             LookAt(unit.transform.position);
             GetUnitAnimator().SetTrigger("isAttacking");
             GetEquippedItemAnimators().ForEach(t => t.SetTrigger("isAttacking"));
             SyncAnimators();
         }
         else
         {
             StartCoroutine(RefreshTargetEvery());
         }
     }
 }
示例#10
0
 [Test] public void CombineUnits()
 {
     Assert.Equal(Unit_.CombineUnits("", "", divide: false), "");
     Assert.Equal(Unit_.CombineUnits("", "", divide: true), "");
     Assert.Equal(Unit_.CombineUnits("1", "1", divide: false), "");
     Assert.Equal(Unit_.CombineUnits("1", "1", divide: true), "");
     Assert.Equal(Unit_.CombineUnits("1", "A", divide: false), "A");
     Assert.Equal(Unit_.CombineUnits("1", "A", divide: true), "1/A");
     Assert.Equal(Unit_.CombineUnits("1", "A.B", divide: false), "A.B");
     Assert.Equal(Unit_.CombineUnits("1", "A.B", divide: true), "1/A.B");
     Assert.Equal(Unit_.CombineUnits("A", "A", divide: false), "A²");
     Assert.Equal(Unit_.CombineUnits("A", "A", divide: true), "");
     Assert.Equal(Unit_.CombineUnits("A.B", "A", divide: false), "A².B");
     Assert.Equal(Unit_.CombineUnits("12", "12", divide: false), "12²");
     Assert.Equal(Unit_.CombineUnits("A.B", "A", divide: true), "B");
     Assert.Equal(Unit_.CombineUnits("A.B", "A.B", divide: false), "A².B²");
     Assert.Equal(Unit_.CombineUnits("A.B", "A.A", divide: true), "B/A");
     Assert.Equal(Unit_.CombineUnits("A.B/C", "C", divide: false), "A.B");
     Assert.Equal(Unit_.CombineUnits("A/B.C", "B/A", divide: false), "1/C");
     Assert.Equal(Unit_.CombineUnits("A³.B²/C.D^4", "B³.C.D/A².C²", divide: true), "A^5/B.D^5");
 }
示例#11
0
 public static Unit <decimal> ToDecimal(this Unit <double> v)
 {
     return(Unit_.Cast <decimal, double>(v));
 }
示例#12
0
 /// <summary>Convert to Unit<double> </summary>
 public static Unit <double> ToDouble(this Unit <decimal> v)
 {
     return(Unit_.Cast <double, decimal>(v));
 }
示例#13
0
 public Relationship(Unit_ unit, int level)
 {
     this.unit  = unit;
     this.level = level;
 }