Ejemplo n.º 1
0
    public Unit(int type, int owner, int health, int x, int y)
    {
        X      = x;
        Y      = y;
        Health = health;
        Owner  = owner == 0 ? UnitOwner.Friendly : UnitOwner.Enemy;

        switch (type)
        {
        case -1:
            Type = UnitType.Queen;
            break;

        case 0:
            Type = UnitType.Knight;
            break;

        case 1:
            Type = UnitType.Archer;
            break;

        case 2:
            Type = UnitType.Giant;
            break;
        }
    }
Ejemplo n.º 2
0
    public void InitUnit(UnitOwner owner)
    {
        this.owner = owner;

        CreateAimComponent();
        aimComponent.Init(this);
        moralComponent = gameObject.AddComponent <UnitMoralComponent>();

        if (owner == UnitOwner.PLAYER)
        {
            transform.Find("SpriteEnemy").gameObject.SetActive(false);
            transform.Find("SpritePlayer").gameObject.SetActive(true);
            transform.Find("SpritePlayer/shotFire").gameObject.SetActive(false);
            if (transform.Find("SpritePlayer/flag") != null)
            {
                transform.Find("SpritePlayer/flag").gameObject.SetActive(false);
            }
        }
        else
        {
            transform.Find("SpriteEnemy").gameObject.SetActive(true);
            transform.Find("SpriteEnemy/shotFire").gameObject.SetActive(false);
            if (transform.Find("SpriteEnemy/flag") != null)
            {
                transform.Find("SpriteEnemy/flag").gameObject.SetActive(false);
            }
            transform.Find("SpritePlayer").gameObject.SetActive(false);
        }
        soldierSprite = transform.GetComponentInChildren <SoldierSprite>();
        hitpoint      = GetParams().hitpoints;

        SetState(new RunUnitState(this), unitState);
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start ()
 {
     //if (hasAuthority)
     //{
         owner = GetComponent<UnitOwner>();
     //}
 }
Ejemplo n.º 4
0
    public void Init(UnitOwner owner)
    {
        this.owner = owner;
        float x = (owner == UnitOwner.PLAYER) ? MIN_X : MAX_X;

        transform.position = new Vector3(x, -3, -5);
        if (owner == UnitOwner.ENEMY)
        {
            transform.rotation = Quaternion.Euler(0, 180, 0);
        }
    }
Ejemplo n.º 5
0
    //private UnitOwner parent = null;

    public void setOwnerShip( UnitOwner owner)
    {

        if (owner != null)
        {
            //parent = owner;
            this.playerName = owner.playerName;
            //this.playerIndex = owner.playerIndex;
            this.playerNetId = owner.playerNetId;
            this.teamIndex = owner.teamIndex;
        }
    }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start () //awake
 {
     if (!isLocalPlayer) enabled = false;
     owner = GetComponent<UnitOwner>();
     StartCoroutine (InitTeamsNumber() );
 }
Ejemplo n.º 7
0
    public static bool canHeShootHim(UnitOwner p1, UnitOwner p2)
    {
        bool res = true;

        if (friendlyFire == true)
        {
            res = true;
        }
        else
        {
            res = !  UnitOwner.isFriendly(p1, p2); ;
        }
        return res;
    }
Ejemplo n.º 8
0
    /*
    public string playerName
    {
        get
        {
            if (parent)
            {
                return parent.playerName;
            }
            else {
                return _playerName;
            }
        }
        set { _playerName = value; }
    }

    public int teamIndex
    {
        get
        {
            if (parent)
            {
                return parent.teamIndex;
            }
            else {
                return _teamIndex;
            }
        }
        set { _teamIndex = value; }

    }

    public int playerIndex
    {
        get
        {
            if (parent)
            {
                return parent.playerIndex;
            }
            else {
                return _playerIndex;
            }
        }
        set { _playerIndex = value; }

    }
    */




    


    public static bool isFriendly(UnitOwner p1 , UnitOwner p2)
    {
        bool res = false;

        if (p1.playerNetId == p2.playerNetId)
        {
            res = true;
        }
        else
        {
            if (p1.teamIndex > 0)
            {
                if (p1.teamIndex == p2.teamIndex) res = true;
            }
            else
            {
                //res = false;
            }
        }

        return res;
    }
Ejemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     //for a sample these will do
     unitState = UnitState.MOVING;
     unitOwner = UnitOwner.PLAYER;
 }