Пример #1
0
        public Unit(Player p, int x, int y, float movementSpeed, float attackRange, float aggroRange, float rateOfFire)
        {
            this.player = p;
            this.x = x;
            this.y = y;
            this.z = 1f - ( this.player.units.Count() + 1) * 0.0001f;
            this.movementSpeed = movementSpeed;
            this.attackRange = attackRange;
            this.aggroRange = aggroRange;
            this.rateOfFire = rateOfFire;

            this.rotation = 0f;
            this.previousRotation = 0f;

            this.hitting = false;
            this.hitFrame = 0;

            this.color = player.color;
            this.waypoints = new CustomArrayList<Point>();

            this.repelsOthers = true;
            this.collisionWith = new CustomArrayList<Unit>();
            this.enemiesInRange = new CustomArrayList<Unit>();
            this.friendliesProtectingMe = new CustomArrayList<Unit>();

            this.job = Job.Idle;

            healthBar = new HealthBar(this);

            this.currentHealth = 100;
            this.maxHealth = 100;

            this.player.units.AddLast(this);

            if (Game1.GetInstance().IsMultiplayerGame())
            {
                Boolean isLocal = this.player == Game1.CURRENT_PLAYER;
                this.multiplayerData = new UnitMultiplayerData(this, isLocal);
                if (isLocal)
                {
                    this.multiplayerData.RequestServerID();
                }

                if (this.multiplayerData != null)
                {
                    // Make sure everyone knows of this unit
                    Synchronizer.GetInstance().QueueUnit(this);
                }
            }
        }
Пример #2
0
        public Unit(Player p, int x, int y, float movementSpeed)
        {
            this.player = p;
            this.x = x;
            this.y = y;
            this.movementSpeed = movementSpeed;
            (this.quad = Game1.GetInstance().quadTree.GetQuadByPoint(this.GetLocation())).highlighted = true;

            this.color = player.color;
            this.waypoints = new LinkedList<Point>();
            this.player.units.AddLast(this);

            this.repelsOthers = true;
            this.collisionWith = new LinkedList<Unit>();

            healthBar = new HealthBar(this);

            this.currentHealth = 100;
            this.maxHealth = 100;
        }
Пример #3
0
        public Unit(Player p, int x, int y, float movementSpeed, float attackRange, float aggroRange, float rateOfFire)
        {
            this.player = p;
            this.x = x;
            this.y = y;
            this.movementSpeed = movementSpeed;
            this.attackRange = attackRange;
            this.aggroRange = aggroRange;
            this.rateOfFire = rateOfFire;
            (this.quad = Game1.GetInstance().quadTree.GetQuadByPoint(this.GetLocation())).highlighted = true;

            this.color = player.color;
            this.waypoints = new LinkedList<Point>();

            this.repelsOthers = true;
            this.collisionWith = new LinkedList<Unit>();
            this.enemiesInRange = new LinkedList<Unit>();
            this.friendliesProtectingMe = new LinkedList<Unit>();

            healthBar = new HealthBar(this);

            this.currentHealth = 100;
            this.maxHealth = 100;

            this.player.units.AddLast(this);

            if (Game1.GetInstance().IsMultiplayerGame())
            {
                Boolean isLocal = this.player == Game1.CURRENT_PLAYER;
                this.multiplayerData = new UnitMultiplayerData(this, isLocal);
                if (isLocal)
                {
                    this.multiplayerData.RequestServerID();
                }
            }
        }