示例#1
0
        public override object Clone()
        {
            Entity newEntity = (Entity)this.MemberwiseClone();

            if (this.Movement != null)
            {
                MovementPattern newMovement = (MovementPattern)this.Movement.Clone();
                newEntity.Movement = newMovement;
            }

            List <Attack> newAttacks = new List <Attack>();

            foreach (Attack attack in this.Attacks)
            {
                Attack newAttack = (Attack)attack.Clone();
                newAttack.Attacker = newEntity;

                newAttack.ExecuteAttackEventHandler += newEntity.LaunchAttack;

                newAttacks.Add(newAttack);
            }

            newEntity.Attacks = newAttacks;

            return(newEntity);
        }
示例#2
0
    void TempBossStunnerButton() // Press 'K' To Stun (& Unstun) Boss
    {
        if (Input.GetKeyDown(KeyCode.K))
        {
            if (currentMovementPattern != MovementPattern.BOSS_STUN)
            {
                previousMovementPattern = currentMovementPattern;
                currentMovementPattern  = MovementPattern.BOSS_STUN;

                if (isOutside == true) // Spawn Boss back inside if Boss was stunned outside
                {
                    transform.position = StageTwoPoints[bossStageTwoMovementEnd[5]].transform.position;

                    isOutside = false;
                }

                Debug.Log("Current Move Pattern = " + currentMovementPattern);
            }
            else
            {
                currentMovementPattern = previousMovementPattern;

                Debug.Log("Current Move Pattern = " + currentMovementPattern);
            }
        }
    }
示例#3
0
 public Circle(Projectile projectile, MovementPattern movement, Timer cooldownToAttack, Timer cooldownToCreateProjectile, int numberOfProjectiles, float degreesToStart, float degreesToEnd)
     : base(projectile, movement, cooldownToAttack, cooldownToCreateProjectile)
 {
     this.numberOfProjectiles = numberOfProjectiles;
     this.degreesToStart      = degreesToStart;
     this.degreesToEnd        = degreesToEnd;
 }
示例#4
0
 public Sprite(Texture2D texture, Color color, MovementPattern movement)
 {
     this.Texture       = texture;
     this.Color         = color;
     this.originalColor = color;
     this.Movement      = movement;
 }
示例#5
0
    // Start is called before the first frame update
    void Start()
    {
        Random.InitState(System.DateTime.Now.Millisecond * GetInstanceID());
        int             index   = Random.Range(0, 3);
        MovementPattern pattern = (MovementPattern)index;

        m_rB = GetComponent <Rigidbody>();

        switch (pattern)
        {
        case MovementPattern.CIRCULAR:
            m_pattern = gameObject.AddComponent <TargetCircularPattern>();
            break;

        case MovementPattern.HORIZONTAL:
            m_pattern = gameObject.AddComponent <TargetHorizontalPattern>();
            break;

        case MovementPattern.SINUSWAVE:
            m_pattern = gameObject.AddComponent <TargetSinusWavePattern>();
            break;

        default:
            m_pattern = gameObject.AddComponent <TargetHorizontalPattern>();
            break;
        }
    }
示例#6
0
 public Enemy(Texture2D texture, Color color, MovementPattern movement, PowerUp powerUp, int hp, List <Attack> attacks)
     : base(texture, color, movement, hp, attacks)
 {
     this.DropLoot       = false;
     this.PowerUp        = powerUp;
     this.PowerUp.Parent = this;
 }
示例#7
0
    void Start()
    {
        movementTimer = 8.0f;

        health = maxHealth;

        previousDestination = 99; // Initializing with a number that is not 0

        playBossLaughAnimation = true;
        bossLaughTriggered     = false;
        bossLaughTimer         = 0.0f;

        currentMovementPattern  = MovementPattern.MOVE_PATTERN_1;
        previousMovementPattern = currentMovementPattern;

        isBulletTurningFirstStart = true;

        navMeshAgent.baseOffset = 2.0f; // Move Boss to starting floating height

        randNum           = Random.Range(6.0f, 8.0f);
        bombingRunRandNum = Random.Range(0, 5);

        bossAppearingSound = SoundManagerScript.mInstance.FindAudioClip(AudioClipID.SFX_BOSS_APPEARING);
        bossAudioSource.PlayOneShot(bossAppearingSound, 1.0f);
    }
示例#8
0
    private void resetAllData()
    {
        m_MovementPattern = MovementPattern.NONE;
        g_ActionQueue     = null;
        g_LastPatrolSpot  = null;
        g_NumberOfActions = 0;
        g_CurrentAction   = 0;

        m_CurWait = 0.0f;
        // m_WaitTotal = 0.01f;
        m_TargetPatrolName        = string.Empty;
        m_NumberOfStaticWaypoints = 0;

        m_StartDynamicWaypoint = null;
        m_FirstDynamicWaypoint = null;
        m_TempWaypointList     = null;
        m_NoiseSource          = null;
        m_NoiseClosestWaypoint = null;

        finalisedRoute      = null;
        finalisedRouteCheck = null;

        m_SlowMoveFactor = 1.0f;
        // m_DistanceBetweenGameObjects = null;
    }
示例#9
0
        /// <inheritdoc />
        public override void SkipTarget()
        {
            // Set the target to be the next in the movement pattern.
            // Replaces the current target no matter the situation.
            Target = MovementPattern.GetNextTarget();

            // Set the new destination for the NavMesh Agent.
            NavMeshAgent.destination = Target.Value;
        }
示例#10
0
        public Attack(Projectile projectile, MovementPattern movement, Timer cooldownToAttack, Timer cooldownToCreateProjectile)
            : base(null, Color.Transparent, movement)
        {
            this.ProjectileToLaunch = projectile;

            this.CooldownToAttack = cooldownToAttack;

            this.CooldownToCreateProjectile = cooldownToCreateProjectile;
        }
示例#11
0
        public override void CreateProjectile(object source, ElapsedEventArgs args)
        {
            // this.PauseTimersWhileDebugging(source as Timer);

            float spacing        = 2;
            int   verticalOffset = 20;

            for (int row = 0; row < this.widthOfArrow; row++)
            {
                for (int col = 0; col <= row; col++)
                {
                    Vector2    targetPosition = GameState.GetPlayerPosition();
                    Projectile newProjectile  = this.ProjectileToLaunch.Clone() as Projectile;
                    newProjectile.Movement        = this.ProjectileToLaunch.Movement.Clone() as MovementPattern;
                    newProjectile.Movement.Parent = newProjectile;

                    if (row < col / 2.0)
                    {
                        Vector2 velocity = MovementPattern.CalculateVelocity(this.Movement.CurrentPosition, targetPosition, newProjectile.Movement.Speed);

                        velocity.X = (float)((velocity.X * Math.Cos((col - (row / 2.0)) * spacing * (Math.PI / 180))) - (velocity.Y * Math.Sin((col - (row / 2.0)) * spacing * (Math.PI / 180))));
                        velocity.Y = (float)((velocity.X * Math.Sin((col - (row / 2.0)) * spacing * (Math.PI / 180))) + (velocity.Y * Math.Cos((col - (row / 2.0)) * spacing * (Math.PI / 180))));

                        newProjectile.Movement.Velocity = velocity;
                    }
                    else if (row == col / 2.0)
                    {
                        Vector2 velocity = MovementPattern.CalculateVelocity(this.Movement.CurrentPosition, targetPosition, newProjectile.Movement.Speed);

                        newProjectile.Movement.Velocity = velocity;
                    }
                    else if (row > col / 2.0)
                    {
                        Vector2 velocity = MovementPattern.CalculateVelocity(this.Movement.CurrentPosition, targetPosition, newProjectile.Movement.Speed);

                        velocity.X = (float)((velocity.X * Math.Cos((col - (row / 2.0)) * spacing * (Math.PI / 180))) - (velocity.Y * Math.Sin((col - (row / 2.0)) * spacing * (Math.PI / 180))));
                        velocity.Y = (float)((velocity.X * Math.Sin((col - (row / 2.0)) * spacing * (Math.PI / 180))) + (velocity.Y * Math.Cos((col - (row / 2.0)) * spacing * (Math.PI / 180))));

                        newProjectile.Movement.Velocity = velocity;
                    }

                    Vector2 position = this.Movement.CurrentPosition;

                    position.Y -= verticalOffset * row;

                    newProjectile.Movement.CurrentPosition = position;

                    newProjectile.Parent = this.Attacker;
                    GameState.Projectiles.Add(newProjectile);
                }
            }

            this.NumberOfTimesProjectilesHaveLaunched++;
        }
示例#12
0
    void Start()
    {
        mRigidbody2D   = GetComponent <Rigidbody2D>();
        mBulletManager = GameObject.Find("BossBulletSpawn").GetComponent <BossBulletManager>();
        mGunMotor      = GameObject.Find("BossBulletSpawn").GetComponent <GunMotor>();
        mHealth        = GetComponent <Health>();

        mMovementPattern   = mBossPhases[mCurrentPhase].data[mCurrentSubPhase].movementPattern;
        mGunMotor.mGunData = mBossPhases[mCurrentPhase].data[mCurrentSubPhase].gunData;
        mGunMotor.initializeGunTimers();
    }
示例#13
0
    // public function
    public void changeMovementPattern(MovementPattern replace, GameObject source, GameObject closest)
    {
        // Change from DYNAMIC to STATIC
        if (replace == MovementPattern.STATIC)
        {
            // Reset Much Data, Much Wow
            resetAllData();

            // A Noise occured, track the source and the closest Waypoint
            m_NoiseSource          = source;
            m_NoiseClosestWaypoint = closest;
            // Generate a Path Starting at the Nearest Waypoint to the Enemy,
            //  Leading to the the closest Waypoint of the Noise
            AI_Static_GeneratePath();
            AI_Static_ListToArray();

            // Instant Turn
            g_TurnRate = 100000.0f;
            AI_RotateToTargetPosition(transform.position, m_NextWaypoint.transform.position);
            g_TurnRate = 1000.0f;

            // Reset MovementPattern, for the Update Functionality to work differently
            m_MovementPattern = replace;
            // For Noise, we increae the Movement Speed
            g_MovementSpeed = g_MovementSpeedHaste;
            // ..
            m_IsHunting = true;
        }

        // Change from STATIC to DYNAMIC
        if (replace == MovementPattern.DYNAMIC)
        {
            // We take the Current Position
            g_LastPatrolSpot = gameObject;

            m_LastWaypoint = m_NoiseClosestWaypoint;
            m_NextWaypoint = m_NoiseClosestWaypoint;
            // Instant Turn
            g_TurnRate = 100000.0f;
            AI_RotateToTargetPosition(transform.position, m_NextWaypoint.transform.position);
            g_TurnRate = 1000.0f;

            // Patrol Movement
            m_CurrentAction = ActionType.PATROL;
            // Reset MovementPattern, for the Update Functionality to work differently
            m_MovementPattern = replace;
            // For Dynamic Movement, we move at Normal Speed
            g_MovementSpeed = g_MovementSpeedNormal;

            m_IsHunting = false;
        }

        UpdateAnimationController();
    }
示例#14
0
 public FinalBoss(Texture2D texture, Color color, MovementPattern movement, PowerUp powerUp, int hp, List <Attack> attacks, List <Attack> phase2Attacks)
     : base(texture, color, movement, powerUp, hp, attacks)
 {
     this.phase2Attacks = phase2Attacks;
     this.initialHP     = hp;
     this.swapToPhase2  = new Timer(5 * 1000);
     this.swapToPhase2.Stop();
     this.swapToPhase2.AutoReset = false;
     this.swapToPhase2.Elapsed  += this.SwitchToPhase2DueToTime;
     this.textureScale           = 1;
     this.points = 1.5;
 }
示例#15
0
        //Takes a movement type, origin, direction, and speed to make the corresponding movement
        public static Movement CreateMovement(MovementPattern pattern, Vector2 origin, Vector2 direction, float velocity)
        {
            AbstractMovementFactory factory = MakeFactory(pattern);

            if (factory != null)
            {
                return(factory.Create(origin, direction, velocity));
            }
            else
            {
                return(null);
            }
        }
示例#16
0
 public void SetDynamicWaypoints(GameObject last, GameObject next)
 {
     m_LastWaypoint = last;
     m_NextWaypoint = next;
     // Instant Turn
     g_TurnRate = 100000.0f;
     AI_RotateToTargetPosition(transform.position, m_NextWaypoint.transform.position);
     g_TurnRate = 1000.0f;
     // Next Patrol Name
     m_TargetPatrolName = next.GetComponent <WaypointTreeNode>().getName();
     m_CurrentAction    = ActionType.PATROL;
     m_MovementPattern  = MovementPattern.DYNAMIC;
 }
示例#17
0
        public void Name_SetSameValue_SameValueTrue()
        {
            var movementPattern   = new MovementPattern(null);
            var movementPatternVM = new MovementPatternVM(movementPattern)
            {
                Name = "Pattern 1"
            };

            movementPatternVM.Name = "Pattern 1";

            string actual = movementPatternVM.Name;

            Assert.AreEqual("Pattern 1", actual);
        }
 void switchSubPhases()
 {
     if (mCurrentSubPhase + 1 < mBossPhases[mCurrentPhase].data.Length)
     {
         if (((float)mHealth.mCurrentHealth / mHealth.mStartHealth) * 100 < mBossPhases[mCurrentPhase].data[mCurrentSubPhase + 1].healthPercent)
         {
             mCurrentSubPhase++;
             mCurrentSubPhase  %= mBossPhases[mCurrentPhase].data.Length;
             mMovementPattern   = mBossPhases[mCurrentPhase].data[mCurrentSubPhase].movementPattern;
             mGunMotor.mGunData = mBossPhases[mCurrentPhase].data[mCurrentSubPhase].gunData;
             mGunMotor.initializeGunTimers();
         }
     }
 }
示例#19
0
 public EnemyConfig(EnemyConfig copy)
 {
     this.enemyType       = copy.enemyType;
     this.movementPattern = copy.movementPattern;
     this.health          = copy.health;
     this.acceleration    = copy.acceleration;
     this.velocity        = copy.velocity;
     this.randomSpawn     = copy.randomSpawn;
     this.fireRate        = copy.fireRate;
     this.direction       = new Position(copy.direction);
     this.bulletType      = copy.bulletType;
     this.count           = copy.count;
     this.spawnInterval   = copy.spawnInterval;
 }
示例#20
0
        public void Name_SetDifferentValue_FirstValueFalse()
        {
            var movementPattern   = new MovementPattern(null);
            var movementPatternVM = new MovementPatternVM(movementPattern)
            {
                Name = "Pattern 1"
            };

            movementPatternVM.Name = "Pattern 2";

            string actual = movementPatternVM.Name;

            Assert.AreNotEqual("Pattern 1", actual);
        }
        private static Attack CreateAttack(Dictionary <string, object> attackProperties)
        {
            Attack attack = null;

            string          attackName = (string)attackProperties["attackName"];
            Projectile      projectile = ProjectileFactory.CreateProjectile((Dictionary <string, object>)attackProperties["projectile"]);
            MovementPattern movement   = MovementPatternFactory.CreateMovementPattern((Dictionary <string, object>)attackProperties["movementPattern"]);

            Timer cooldownToAttack = EntityGroupBuilder.CreateTimer((float)attackProperties["cooldownToAttack"]);

            cooldownToAttack.Stop();
            cooldownToAttack.AutoReset = true;

            Timer cooldownToCreateProjectile = EntityGroupBuilder.CreateTimer((float)attackProperties["cooldownToCreateProjectile"]);

            cooldownToCreateProjectile.Stop();
            cooldownToCreateProjectile.AutoReset = true;

            switch (attackName)
            {
            case "basicLinear":
                attack = new BasicLinear(projectile, movement, cooldownToAttack, cooldownToCreateProjectile);
                break;

            case "circularHoming":
                attack = new CircularHoming(projectile, (Circular)movement, cooldownToAttack, cooldownToCreateProjectile);
                break;

            case "circularTriHoming":
                attack = new CircularTriHoming(projectile, (Circular)movement, cooldownToAttack, cooldownToCreateProjectile);
                break;

            case "circle":
                int   numberOfProjectiles = Convert.ToInt32((float)attackProperties["numberOfProjectiles"]);
                float degreesToStart      = (float)attackProperties["degreesToStart"];
                float degreesToEnd        = (float)attackProperties["degreesToEnd"];
                attack = new Circle(projectile, movement, cooldownToAttack, cooldownToCreateProjectile, numberOfProjectiles, degreesToStart, degreesToEnd);
                break;

            case "arrow":
                int widthOfArrow = Convert.ToInt32((float)attackProperties["widthOfArrow"]);
                attack = new Arrow(projectile, movement, cooldownToAttack, cooldownToCreateProjectile, widthOfArrow);
                break;

            default:
                throw new Exception("Invalid Entity");
            }

            return(attack);
        }
示例#22
0
        public IEncodable Decode(BinaryInput stream)
        {
            this.Pattern      = (MovementPattern)stream.ReadByte();
            this.Speed        = (MovementSpeed)stream.ReadByte();
            this.Count        = stream.ReadInt16();
            this.CurrentIndex = stream.ReadInt16();
            this.Inverted     = stream.ReadBoolean();
            int c = stream.ReadInt32();

            for (int i = 0; i < c; i++)
            {
                Movements.Add(stream.ReadObject <Movement>());
            }
            return(this);
        }
示例#23
0
    public void SetSavedData(XmlConstruct setup)
    {
        // Set Position
        transform.position = setup.CurrentPosition;
        // Set Rotation
        transform.rotation = new Quaternion(setup.CurrentRotation.x, setup.CurrentRotation.y, setup.CurrentRotation.z, 1.0f);

        GameObject[] list = GameObject.FindGameObjectsWithTag(StringManager.Tags.Waypoints);
        for (int i = 0; i < list.Length; i++)
        {
            // Set LastWaypoint
            if (list[i].name.Equals(setup.LastWaypointName))
            {
                m_LastWaypoint = list[i];
            }

            // Set NextWaypoint
            if (list[i].name.Equals(setup.NextWaypointName))
            {
                m_NextWaypoint     = list[i];
                m_TargetPatrolName = m_NextWaypoint.GetComponent <WaypointTreeNode>().getName();
            }

            // Set Closest Noise Waypoint
            if (list[i].name.Equals(setup.HuntingWaypointName))
            {
                m_NoiseClosestWaypoint = list[i];
            }

            // Set Noise Source
            if (list[i].name.Equals(setup.HuntingWaypointSourceName))
            {
                m_NoiseSource = list[i];
            }
        }

        // Set Movement Pattern
        m_MovementPattern = setup.Pattern;

        // Set Hunting State
        m_IsHunting = setup.IsHunting;

        // If Hunting, just to be save, order Pattern Change
        if (m_IsHunting)
        {
            changeMovementPattern(MovementPattern.STATIC, m_NoiseSource, m_NoiseClosestWaypoint);
        }
    }
示例#24
0
    private void GenerateNewPattern()
    {
        if (!_lastSpotted.HasValue)
        {
            return;
        }

        var lastSpotted  = _lastSpotted.Value;
        var positionList = Game.PatternGenerator.GeneratePattern(lastSpotted, gameObject);

        MovementPattern.SetNewPattern(positionList);

        // Skip ahead to the next target.
        // This is to prevent the guard from walking to the last pattern.
        MovementHandler.SkipTarget();
    }
示例#25
0
        public override object Clone()
        {
            Attack newAttack = (Attack)this.MemberwiseClone();

            if (this.Movement != null)
            {
                MovementPattern newMovement = (MovementPattern)this.Movement.Clone();
                newAttack.Movement = newMovement;
            }

            Projectile newProjectile = (Projectile)this.ProjectileToLaunch.Clone();

            newAttack.ProjectileToLaunch = newProjectile;

            newAttack.Attacker = this.Attacker;

            newAttack.NumberOfTimesProjectilesHaveLaunched = 0;

            newAttack.isClone = true;

            Timer newCooldownToAttackTimer = new Timer(newAttack.CooldownToAttack.Interval);

            newCooldownToAttackTimer.AutoReset = newAttack.CooldownToAttack.AutoReset;
            newCooldownToAttackTimer.Enabled   = newAttack.CooldownToAttack.Enabled;
            newCooldownToAttackTimer.Elapsed  += newAttack.ExecuteAttack;
            newAttack.CooldownToAttack         = newCooldownToAttackTimer;

            Timer newCooldownToCreateProjectile = new Timer(newAttack.CooldownToCreateProjectile.Interval);

            newCooldownToCreateProjectile.AutoReset = newAttack.CooldownToCreateProjectile.AutoReset;
            newCooldownToCreateProjectile.Enabled   = newAttack.CooldownToCreateProjectile.Enabled;
            newCooldownToCreateProjectile.Elapsed  += newAttack.CreateProjectile;
            newAttack.CooldownToCreateProjectile    = newCooldownToCreateProjectile;

            if (newAttack.ExecuteAttackEventHandler != null)
            {
                foreach (Delegate d in newAttack.ExecuteAttackEventHandler.GetInvocationList())
                {
                    newAttack.ExecuteAttackEventHandler -= (EventHandler)d;
                }
            }

            // Debug.WriteLine(DateTime.Now + ": " + newAttack.GetHashCode() + " has been created from clone.");

            return(newAttack);
        }
示例#26
0
        public Player(Texture2D texture, Color color, MovementPattern movement, int hp, List <Attack> attacks)
            : base(texture, color, movement, hp, attacks)
        {
            this.textureScale = 1.5F;
            this.spawning     = true;
            this.Invincible   = true;
            this.DamageLevel  = 0;
            this.points       = 0;

            foreach (Attack attack in attacks)
            {
                attack.CooldownToAttack.Elapsed  += attack.ExecuteAttack;
                attack.ExecuteAttackEventHandler += this.LaunchAttack;
                attack.Attacker = this;
                attack.ProjectileToLaunch.Parent = attack;
            }
        }
示例#27
0
        //Makes the corresponding movement factory and returns it
        public static AbstractMovementFactory MakeFactory(MovementPattern pattern)
        {
            AbstractMovementFactory factory = null;

            switch (pattern)
            {
            case MovementPattern.Straight:
                factory = new StraightPattern();
                break;

            case MovementPattern.Oscillate:
                factory = new OscillatePattern();
                break;
            }

            return(factory);
        }
    void moveToPoints()
    {
        MovementPattern currentPattern = mMovementPattern;
        Vector2         diff           = currentPattern.data[currentPattern.mCurrentTargetIndex].target - (Vector2)transform.position;

        if (Mathf.Abs(diff.magnitude) <= mTargetRadius)
        {
            currentPattern.mCurrentTargetIndex++;
            currentPattern.mCurrentTargetIndex %= currentPattern.data.Length;
            mBulletManager.mShouldBeFiring      = currentPattern.data[currentPattern.mCurrentTargetIndex].shootOnArrive;
            mRigidbody2D.velocity = Vector2.zero;
            return;
        }

        float targetSpeed = 0;

        if (diff.magnitude > mSlowRadius)
        {
            targetSpeed = currentPattern.data[currentPattern.mCurrentTargetIndex].speedToTarget;
        }
        else
        {
            targetSpeed = currentPattern.data[currentPattern.mCurrentTargetIndex].speedToTarget * diff.magnitude / mTimeToTarget;
        }

        Vector2 targetVelocity = diff;

        targetVelocity.Normalize();
        targetVelocity *= targetSpeed;

        Vector2 acceleration = targetVelocity - mRigidbody2D.velocity;

        acceleration /= mTimeToTarget;

        if (acceleration.magnitude > mMaxAcceleration)
        {
            acceleration.Normalize();
            acceleration *= mMaxAcceleration;
        }

        mRigidbody2D.AddForce(acceleration);

        mBulletManager.mShouldBeFiring = currentPattern.data[currentPattern.mCurrentTargetIndex].shootOnTravel;
        return;
    }
示例#29
0
        public IEnumerable <HillContent> GetPositions(MovementPattern pattern)
        {
            var verticalIndex   = 0;
            var horizontalIndex = 0;

            do
            {
                yield return(Hill[verticalIndex][horizontalIndex]);

                verticalIndex   += pattern.Vertical;
                horizontalIndex += pattern.Horizontal;
                horizontalIndex  = horizontalIndex % Hill[0].Length;
                if (horizontalIndex == Hill[0].Length)
                {
                    horizontalIndex = 0;
                }
            } while (verticalIndex < Hill.Length);
        }
示例#30
0
    void Start()
    {
        enemyGrid   = new bool[columnCount, rowCount];
        enemyHolder = new GameObject("Enemies").transform;

        enemyWaveManager = this.GetComponent <EnemyWaveManager>();
        patterns         = this.GetComponent <MovementPattern>();

        validColumns = new List <int> ();        //List of index of columns on which enemies can spawn and move
        //The grid is divided in sectors next to each other
        //The activeSectors (here startingSectors) are the index of the current active sectors (ex: sector 1, 2 and 4)
        UpdateValidColumns(sectors, startingSectors);

        inclineAngleRad = arenaIncline * Mathf.Deg2Rad;
        tileAngleRad    = 2 * Mathf.PI / columnCount;
        //sectorSize = columnCount / sectors;
        sectorSize = 7;
    }
示例#31
0
		public IEncodable Decode(BinaryInput stream) {
			this.Pattern = (MovementPattern) stream.ReadByte();
			this.Speed = (MovementSpeed) stream.ReadByte();
			this.Count = stream.ReadInt16();
			this.CurrentIndex = stream.ReadInt16();
			this.Inverted = stream.ReadBoolean();
			int c = stream.ReadInt32();
			for (int i = 0; i < c; i++) {
				Movements.Add(stream.ReadObject<Movement>());
			}
			return this;
		}
示例#32
0
        /// <summary>
        /// Create unit of specific type at specific location.
        /// All other parameters (hitpoints, etc.) are set from UnitManager.
        /// </summary>
        /// <param name="setType">Set type</param>
        /// <param name="setPosition">Set position</param>
        /// <param name="setMovementPattern">Movement pattern</param>
        public Unit(UnitTypes setType, Vector2 setPosition,
			MovementPattern setMovementPattern)
        {
            unitType =
                setType;
                //(Unit.UnitTypes)RandomHelper.GetRandomInt(5);
            position = setPosition;
            movementPattern = setMovementPattern;
            // Don't allow swing left/right for asteroid
            if (unitType == UnitTypes.Asteroid)
                movementPattern = MovementPattern.StraightDown;

            // Recalculate our unit values and reset hitpoints to 100%.
            maxHitpoints = hitpoints = DefaultUnitHitpoints[(int)unitType];
            cooldownTime = DefaultCooldownTime[(int)unitType];
            damage = DefaultUnitDamage[(int)unitType];
            explosionDamage = DefaultExplosionDamage[(int)unitType];
            maxSpeed = DefaultMaxSpeed[(int)unitType];
            shootTime = 0;
            lifeTimeMs = 0;
        }