예제 #1
0
 public void iWasHit(GameObject attacker)
 {
     //If I was hit then target agressor and we are on attack stance
     if (attackState == AttackState.ATTACK)
     {
         target.Reset();
         target = new TargetObject(attacker);
     }
 }
예제 #2
0
    public void UpdateTargetPos(Vector3 targetPos, GameObject obj)
    {
        if (obj != null)
        {
            target = new TargetObject(obj);

            //Do not go somewhere we shouldn't according to our flags

            //We can mine or attach or bomb and the target is a resource
            if ((canAttachTo || canMine || bomber) && target.objID.objID == ObjectID.OBJECTID.RESOURCE)
            {
                //Find a position
                target.tarObjectAdjustPos = GetAdjustedPos();
            }
            //We can attack or repair and the target is a building that we own
            else if ((canAttachTo || canRepair) && target.objID.objID == ObjectID.OBJECTID.BUILDING && target.objID.ownerPlayerID == objID.ownerPlayerID)
            {
                //Find a position
                target.tarObjectAdjustPos = GetAdjustedPos();
            }
            //We can fight or attack or we are a bomber and the target is a building or unit the enemy owns
            else if ((canFight || canAttachTo || bomber) && (target.objID.objID == ObjectID.OBJECTID.BUILDING || target.objID.objID == ObjectID.OBJECTID.UNIT) && target.objID.ownerPlayerID != objID.ownerPlayerID)
            {
                //Do not boost a unit
                if (canAttachTo && target.objID.objID == ObjectID.OBJECTID.BUILDING)
                {
                    //Find a position
                    target.tarObjectAdjustPos = GetAdjustedPos();
                }
                else if (!canAttachTo)
                {
                    //Find a position
                    target.tarObjectAdjustPos = GetAdjustedPos();
                }
            }
            else
            {
                Debug.Log($"Invalid Request From UpdateTargetPos on Object [{gameObject.name}], check flags");
                target.Reset();
            }
        }
        else
        {
            //Go to pos
            target = new TargetObject(targetPos);
        }
    }