Exemple #1
0
        void WarShip_OnShoot(WarShip firer, Vector2 endPoint, float azi)
        {
            if (PurviewMgr.IsMainHost)
            {
                WarShipShell shell = new WarShipShell("shell" + shellcount, firer, endPoint, azi);
                shell.onCollided += new OnCollidedEventHandler(Shell_onCollided);
                shell.OnOutDate  += new WarShipShell.ShellOutDateEventHandler(Shell_OnOutDate);
                sceneMgr.AddGameObj("shell", shell);


                SyncCasheWriter.SubmitCreateObjMg("shell", typeof(WarShipShell), "shell" + shellcount, firer, endPoint, azi);
                shellcount++;
            }
        }
Exemple #2
0
        void tank_onShoot(Tank sender, Vector2 turretEnd, float azi)
        {
            if (PurviewMgr.IsMainHost)
            {
                ShellNormal shell = new ShellNormal("shell" + shellSum.ToString(), sender, turretEnd, azi, shellSpeed);
                sceneMgr.AddGameObj("shell", shell);

                shell.onCollided += new OnCollidedEventHandler(shell_onCollided);
                shellSum++;
                SyncCasheWriter.SubmitCreateObjMg("shell", typeof(ShellNormal), shell.Name, sender, turretEnd, azi, shellSpeed);
            }

            Sound.PlayCue("CANNON1");
        }
Exemple #3
0
        private void CreateRock()
        {
            if (PurviewMgr.IsMainHost)
            {
                Vector2 newPos = new Vector2();
                while (true)
                {
                    newPos = RandomHelper.GetRandomVector2(-100, 100);

                    int posType = RandomHelper.GetRandomInt(0, 2);

                    if (posType == 0)
                    {
                        if (newPos.X < 0)
                        {
                            newPos.X -= mapRect.X + AddObjSpace;
                        }
                        else
                        {
                            newPos.X += mapRect.Width + mapRect.X + AddObjSpace;
                        }

                        if (newPos.Y < 0)
                        {
                            newPos.Y -= mapRect.Y + AddObjSpace;
                        }
                        else
                        {
                            newPos.Y += mapRect.Y + mapRect.Height + AddObjSpace;
                        }
                    }
                    else if (posType == 1)
                    {
                        newPos.X *= mapRect.Width / 200;
                        newPos.X += mapRect.Width / 2 + mapRect.X;

                        if (newPos.Y < 0)
                        {
                            newPos.Y -= mapRect.Y + AddObjSpace;
                        }
                        else
                        {
                            newPos.Y += mapRect.Y + mapRect.Height + AddObjSpace;
                        }
                    }
                    else if (posType == 2)
                    {
                        newPos.Y *= mapRect.Height / 200;
                        newPos.Y += mapRect.Y + mapRect.Height / 2;

                        if (newPos.X < 0)
                        {
                            newPos.X -= mapRect.X + AddObjSpace;
                        }
                        else
                        {
                            newPos.X += mapRect.Width + mapRect.X + AddObjSpace;
                        }
                    }
                    if (CanAddObjAtPos(newPos))
                    {
                        break;
                    }
                }
                float   speed = RandomHelper.GetRandomFloat(SpaceWarConfig.RockMinSpeed, SpaceWarConfig.RockMaxSpeed);
                Vector2 way   = Vector2.Normalize(MapCenterPos - newPos);
                Vector2 delta = RandomHelper.GetRandomVector2(-0.7f, 0.7f);
                Vector2 Vel   = Vector2.Normalize(way + delta) * speed;

                float aziVel = RandomHelper.GetRandomFloat(0, SpaceWarConfig.RockMaxAziSpeed);
                float scale  = RandomHelper.GetRandomFloat(0.4f, 1.4f);
                int   kind   = RandomHelper.GetRandomInt(0, ((int)RockTexNo.Max) - 1);

                Rock newRock = new Rock("Rock" + rockCount, newPos, Vel, aziVel, scale, kind);

                newRock.OnCollided += new OnCollidedEventHandler(Rock_OnCollided);
                sceneMgr.AddGameObj("rock", newRock);

                rocks.Add(newRock);
                SyncCasheWriter.SubmitCreateObjMg("rock", typeof(Rock), "Rock" + rockCount, newPos, Vel, aziVel, scale, kind);

                rockCount++;
            }
        }