コード例 #1
0
ファイル: Game1.cs プロジェクト: elena1905/Games-Engines-1
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            playerTank = new Tank();
            enemyTank  = new AITank();

            enemyTank.pos = new Vector2(ScreenWidth / 2, 400);

            children.Add(playerTank);
            children.Add(enemyTank);

            for (int i = 0; i < children.Count(); i++)
            {
                children[i].Initialize();
            }

            base.Initialize();
        }
コード例 #2
0
        public void UpdateTarget(float dt, List <AITank> Tanks)
        {
            target = null;
            double distanceToTarget = -1;
            double distanceToTank;

            foreach (AITank aTank in Tanks)
            {
                distanceToTank = Math.Sqrt((getPosition().X *getPosition().X - aTank.getPosition().X *aTank.getPosition().X) + (getPosition().Z *getPosition().Z - aTank.getPosition().Z *aTank.getPosition().Z));
                distanceToTank = Math.Abs(distanceToTank);
                if (distanceToTank < distanceToTarget || distanceToTarget == -1 && aTank != this)
                {
                    target           = aTank;
                    distanceToTarget = distanceToTank;
                }
            }
            UpdateState(dt, distanceToTarget);
        }
コード例 #3
0
        public void reset()
        {
            tanks.Clear();
            objects.Clear();

            for (int i = 0; i < initialNoOfTanks; i++)
            {
                var tank = new AITank(Content);
                tanks.Add(tank);
                objects.Add(tank);
                //add tank to map at random position
                //add tank to tank list
                //add tank to object list
            }

            for (int i = 0; i < initialNoOfPhysicalObjects; i++)
            {
            }
        }
コード例 #4
0
ファイル: Game1.cs プロジェクト: elena1905/Games-Engines-1
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            playerTank = new Tank();
            enemyTank = new AITank();

            enemyTank.pos = new Vector2(ScreenWidth / 2, 400);

            children.Add(playerTank);
            children.Add(enemyTank);

            for ( int i = 0; i < children.Count(); i++ )
            {
                children[i].Initialize();
            }

            base.Initialize();
        }
コード例 #5
0
 public void UpdateTarget(float dt, List<AITank> Tanks)
 {
     target = null;
     double distanceToTarget = -1;
     double distanceToTank;
     foreach (AITank aTank in Tanks)
     {
         distanceToTank = Math.Sqrt((getPosition().X * getPosition().X - aTank.getPosition().X * aTank.getPosition().X) + (getPosition().Z * getPosition().Z - aTank.getPosition().Z * aTank.getPosition().Z));
         distanceToTank = Math.Abs(distanceToTank);
         if (distanceToTank < distanceToTarget || distanceToTarget == -1 && aTank != this)
         {
             target = aTank;
             distanceToTarget = distanceToTank;
         }
     }
     UpdateState(dt, distanceToTarget);
 }
コード例 #6
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            basis = new Vector2(0, -1);

            playerTank = new Tank();
            enemyTank = new AITank();

            children.Add(playerTank);
            children.Add(enemyTank);

            for ( int i = 0; i < children.Count(); i++ )
            {
                children[i].Initialize();
            }

            base.Initialize();
        }
コード例 #7
0
        public void reset()
        {
            tanks.Clear();
            objects.Clear();

            for (int i = 0; i < initialNoOfTanks; i++)
            {

                var tank = new AITank(Content);
                tanks.Add(tank);
                objects.Add(tank);
                //add tank to map at random position
                //add tank to tank list
                //add tank to object list

            }

            for (int i = 0; i < initialNoOfPhysicalObjects; i++)
            {

            }
        }