Пример #1
0
        public override void update(GameTime gameTime)
        {
            if (Math.Abs((position - m_vTargetPosition).Length()) <= 20)
            {
                // Asplode.
                BigExplosion exp = new BigExplosion(position);
                Firecracker.level.addObject(exp);
                this.toBeDeleted = true;

                Firecracker.level.attackSettlements(exp.position, 200);

                // find all the NPCs nearby and kill 'em all. MUAUAhahah.....ha
                for (int i = 0; i < Firecracker.level.numberOfObjects(); i++)
                {
                    GameObject theObj = Firecracker.level.objectAt(i);
                    if (theObj.GetType() == typeof(NPCObject))
                    {
                        if ((theObj.position - position).Length() < 120)
                        {
                            // kill this guy.
                            theObj.toBeDeleted = true;
                            HumanDeath newDeath = new HumanDeath(theObj.position);
                            Firecracker.level.addObject(newDeath);
                            if ((theObj.position - position).Length() < 60)
                            {
                                Explosion explosionDeath = new Explosion(theObj.position);
                                Firecracker.level.addObject(explosionDeath);
                            }
                        }
                        if ((theObj.position - position).Length() < 180)
                        {
                            NPCObject person = (NPCObject)theObj;
                            person.wanderType    = AIWanderType.AI_Scatter;
                            person.PointOfTerror = new Vector2(position.X, position.Y);
                            person.eventTime     = 1.2f;
                            person.FleeFromPoint(person.PointOfTerror);
                        }
                    }
                }
            }
            else
            {
                // Fly in
                Vector2 newPos = m_vTargetPosition - position;
                newPos.Normalize();
                newPos   *= (float)(m_fSpeed * gameTime.ElapsedGameTime.TotalSeconds);
                position += newPos;
            }

            base.update(gameTime);
        }
Пример #2
0
        public override void update(GameTime gameTime)
        {
            personality(gameTime);
            if (m_bKillable)
            {
                m_fAge += (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            if (m_fAge >= m_fDeathAt)
            {
                diedNaturally = true;
                //Explosion exp = new Explosion(position + new Vector2(16.0f, 16.0f));
                //Firecracker.level.addObject(exp);
                //Explosion exp2 = new Explosion(position - new Vector2(16.0f, 16.0f));
                //Firecracker.level.addObject(exp2);

                if (Firecracker.engineInstance.numPeoples <= 500)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        Vector2 spawnPosition = position;
                        for (int j = 0; j < 5; j++)
                        {
                            //try 5 times to find a legal spawn position
                            spawnPosition = position + new Vector2((float)Firecracker.random.NextDouble() * 32 - 16, (float)Firecracker.random.NextDouble() * 32 - 16);
                            if (Terrain.Instance == null || Terrain.Instance.isPositionWalkable(spawnPosition))
                            {
                                break;
                            }
                            spawnPosition = position;
                        }

                        NPCObject newObject = new NPCObject(spawnPosition, this);
                        Firecracker.level.addObject(newObject);
                    }

                    HumanDeath newDeath = new HumanDeath(position);
                    Firecracker.level.addObject(newDeath);

                    toBeDeleted = true;
                }
            }

            // until we can see the cursor, don't worry about this.
            //if (Firecracker.engineInstance.m_MouseManager.IsMouseLeftPressed())
            //{
            //    FleeFromPoint(Firecracker.engineInstance.m_MouseManager.GetMousePos());
            //}

            base.update(gameTime);
        }
Пример #3
0
        public override void update(GameTime gameTime)
        {
            for (int i = 0; i < m_lFireObjects.Count(); i++)
            {
                FireNode theNode = m_lFireObjects[i];
                Vector2  newPos  = theNode.m_vTargetLocation - m_lFireObjects[i].m_vCurrentLocation;
                newPos.Normalize();
                newPos *= (float)(m_lFireObjects[i].m_fSpeed * gameTime.ElapsedGameTime.TotalSeconds);
                theNode.m_vCurrentLocation    = m_lFireObjects[i].m_vCurrentLocation + newPos;
                theNode.m_fLifeLeft          -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                theNode.m_FireObject.position = theNode.m_vCurrentLocation;

                m_lFireObjects[i] = theNode;

                if (m_lFireObjects[i].m_fLifeLeft <= 0)
                {
                    CreateNewNode(m_lFireObjects[i].m_vCurrentLocation, m_lFireObjects[i].m_iNodesRemaining - 1);
                    CreateNewNode(m_lFireObjects[i].m_vCurrentLocation, m_lFireObjects[i].m_iNodesRemaining - 1);
                    m_lFireObjects.RemoveAt(i);
                    i--;
                    continue;
                }


                // check the collisions.
                for (int j = 0; j < Firecracker.level.numberOfObjects(); j++)
                {
                    GameObject theObj = Firecracker.level.objectAt(j);
                    if (theObj.GetType() == typeof(NPCObject))
                    {
                        if ((theObj.position - m_lFireObjects[i].m_vCurrentLocation).Length() < 10)
                        {
                            // kill this guy.
                            theObj.toBeDeleted = true;
                            Explosion  newDeath = new Explosion(theObj.position);
                            HumanDeath ashDeath = new HumanDeath(theObj.position);
                            Firecracker.level.addObject(newDeath);
                            Firecracker.level.addObject(ashDeath);
                        }
                    }
                }
            }
            base.update(gameTime);
        }