Exemplo n.º 1
0
 void WarShip_OnDead(WarShip sender)
 {
     destoryAnimate.SetSpritesParameters(new Vector2(48, 48), this.Pos, 1f, this.Azi, Color.White, LayerDepth.TankBase, SpriteBlendMode.AlphaBlend);
     destoryAnimate.Interval = 5;
     destoryAnimate.Start(0, 6, true);
     GameManager.AnimatedMgr.Add(destoryAnimate);
 }
Exemplo n.º 2
0
 void WarShip_OnDead(WarShip sender)
 {
     destoryAnimate.SetSpritesParameters(new Vector2(48, 48), this.Pos, 1f, this.Azi, Color.White, LayerDepth.TankBase, SpriteBlendMode.AlphaBlend);
     destoryAnimate.Interval = 5;
     destoryAnimate.Start(0, 6, true);
     GameManager.AnimatedMgr.Add(destoryAnimate);
 }
Exemplo n.º 3
0
        void WarShip_OnCollied(IGameObj Sender, CollisionResult result, GameObjInfo objB)
        {
            if (objB.ObjClass == "WarShipShell")
            {
                WarShip ship = (WarShip)Sender;
                ship.BeginStill();
                if (PurviewMgr.IsMainHost)
                {
                    ship.HitByShell();
                }
                ship.Vel = result.NormalVector * SpaceWarConfig.ShellSpeed;

                SyncShipScoreHp(ship, false);
            }
            else if (objB.ObjClass == "WarShip")
            {
                WarShip ship   = (WarShip)Sender;
                Vector2 newVel = CalMirrorVel(ship.Vel, result.NormalVector);
                ship.Vel = newVel;
                ship.BeginStill();
            }
            else if (objB.ObjClass == "Rock")
            {
                WarShip ship   = (WarShip)Sender;
                Vector2 newVel = CalMirrorVel(ship.Vel, result.NormalVector);
                ship.Vel = newVel;
                ship.BeginStill();
            }
        }
Exemplo n.º 4
0
 public void CallOnShoot(WarShip firer, Vector2 endPoint, float azi)
 {
     if (OnShoot != null)
     {
         OnShoot(this, Pos + MathTools.NormalVectorFromAzi(azi) * SpaceWarConfig.ShootEndDest, azi);
     }
 }
Exemplo n.º 5
0
        void Shell_onCollided(IGameObj Sender, CollisionResult result, GameObjInfo objB)
        {
            if (objB.ObjClass == "WarShip")
            {
                if (PurviewMgr.IsMainHost)
                {
                    WarShipShell shell = Sender as WarShipShell;
                    WarShip      firer = shell.Firer as WarShip;
                    if (objB.Script != firer.ObjInfo.Script)
                    {
                        (shell.Firer as WarShip).Score += SpaceWarConfig.ScoreByHit;
                        SyncShipScoreHp(shell.Firer as WarShip, true);
                    }
                }

                sceneMgr.DelGameObj("shell", Sender.Name);
                new ShellExplodeBeta(Sender.Pos, ((ShellNormal)Sender).Azi);

                Quake.BeginQuake(10, 50);
                Sound.PlayCue("EXPLO1");
            }
            else
            {
                WarShipShell shell = (WarShipShell)Sender;
                shell.MirrorPath(result);

                //
                //BroadcastObjPhiStatus(shell, true);
            }
        }
Exemplo n.º 6
0
 void SyncCasheReader_onUserDefineInfo(string infoName, string infoID, object[] args)
 {
     if (infoName == "WarshipBorn")
     {
         WarShip ship = args[0] as WarShip;
         if (!PurviewMgr.IsMainHost)
         {
             ship.Dead();
         }
         ship.Born((Vector2)args[1]);
     }
     else if (infoName == "ObjPhiCollide")
     {
         if (args[0] != null)
         {
             ((NonInertiasPhiUpdater)((args[0] as IPhisicalObj).PhisicalUpdater))
             .SetServerStatue((Vector2)args[1], (Vector2)args[2], (float)args[3], (float)args[4], phiSyncTime, true);
         }
     }
     else if (infoName == "ObjPhi")
     {
         if (args[0] != null &&
             args[0] != ships[controlIndex])
         {
             ((NonInertiasPhiUpdater)((args[0] as IPhisicalObj).PhisicalUpdater))
             .SetServerStatue((Vector2)args[1], (Vector2)args[2], (float)args[3], (float)args[4], phiSyncTime, false);
         }
     }
     else if (infoName == "Score")
     {
         if (args[0] != null)
         {
             WarShip ship = args[0] as WarShip;
             ship.Score = (int)args[1];
         }
     }
     else if (infoName == "Hp")
     {
         if (args[0] != null)
         {
             WarShip ship = args[0] as WarShip;
             ship.HP = (int)args[1];
         }
     }
     else if (infoName == "GoldBorn")
     {
         if (args[0] != null)
         {
             (args[0] as Gold).Born((Vector2)args[1]);
         }
     }
     else if (infoName == "Over")
     {
         isSendOver = true;
     }
 }
Exemplo n.º 7
0
        void Warship_OnOverLap(IGameObj Sender, CollisionResult result, GameObjInfo objB)
        {
            if (objB.ObjClass == "Gold")
            {
                WarShip ship = Sender as WarShip;
                ship.Score += SpaceWarConfig.GoldScore;

                SyncShipScoreHp(ship, true);
            }
        }
Exemplo n.º 8
0
 private void SyncShipScoreHp(WarShip ship, bool subScore)
 {
     if (PurviewMgr.IsMainHost)
     {
         if (subScore)
         {
             SyncCasheWriter.SubmitUserDefineInfo("Score", "", ship, ship.Score);
         }
         else
         {
             SyncCasheWriter.SubmitUserDefineInfo("Hp", "", ship, ship.HP);
         }
     }
 }
Exemplo n.º 9
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++;
            }
        }
Exemplo n.º 10
0
        private void InitializeScene()
        {
            sceneMgr = new SceneMgr();

            sceneMgr.AddGroup("", new TypeGroup <WarShip>("warship"));
            sceneMgr.AddGroup("", new TypeGroup <WarShipShell>("shell"));
            sceneMgr.AddGroup("", new TypeGroup <SmartTank.PhiCol.Border>("border"));
            sceneMgr.AddGroup("", new TypeGroup <Gold>("gold"));
            sceneMgr.AddGroup("", new TypeGroup <Rock>("rock"));

            sceneMgr.PhiGroups.Add("warship");
            sceneMgr.PhiGroups.Add("shell");
            sceneMgr.PhiGroups.Add("rock");
            sceneMgr.AddColMulGroups("warship", "shell", "border");
            sceneMgr.AddColMulGroups("warship", "shell", "rock");
            sceneMgr.ColSinGroups.Add("warship");
            sceneMgr.ColSinGroups.Add("rock");

            sceneMgr.AddLapMulGroups("warship", "gold");

            ships = new WarShip[playerNames.Length];
            for (int i = 0; i < playerNames.Length; i++)
            {
                bool openControl = false;
                if (i == controlIndex)
                {
                    openControl = true;
                }

                ships[i]            = new WarShip("ship" + i, new Vector2(400 + i * 800, 600), 0, openControl);
                ships[i].OnCollied += new OnCollidedEventHandler(WarShip_OnCollied);
                ships[i].OnOverLap += new OnCollidedEventHandler(Warship_OnOverLap);
                ships[i].OnShoot   += new WarShip.WarShipShootEventHandler(WarShip_OnShoot);
                ships[i].OnDead    += new WarShip.WarShipDeadEventHandler(Warship_OnDead);
                ships[i].PlayerName = playerNames[i];
                sceneMgr.AddGameObj("warship", ships[i]);
            }

            gold                = new Gold("gold", new Vector2(800, 600), 0);
            gold.OnOverLap     += new OnCollidedEventHandler(Gold_OnOverLap);
            gold.OnLiveTimeOut += new Gold.GoldLiveTimeOutEventHandler(Gold_OnLiveTimeOut);

            sceneMgr.AddGameObj("border", new SmartTank.PhiCol.Border(mapRect));
            sceneMgr.AddGameObj("gold", gold);

            GameManager.LoadScene(sceneMgr);

            camera.Focus(ships[controlIndex], false);
        }
Exemplo n.º 11
0
 void Warship_OnDead(WarShip sender)
 {
     //sceneMgr.DelGameObj(sender.MgPath);
     if (PurviewMgr.IsMainHost)
     {
         while (true)
         {
             Vector2 newPos = RandomHelper.GetRandomVector2(0, 1);
             newPos.X *= mapRect.Width;
             newPos.X += mapRect.X;
             newPos.Y *= mapRect.Height;
             newPos.Y += mapRect.Y;
             if (CanAddObjAtPos(newPos))
             {
                 (sender as WarShip).Born(newPos);
                 SyncCasheWriter.SubmitUserDefineInfo("WarshipBorn", "", sender, newPos);
                 break;
             }
         }
     }
 }
Exemplo n.º 12
0
 public void CallOnShoot(WarShip firer, Vector2 endPoint, float azi)
 {
     if (OnShoot != null)
         OnShoot(this, Pos + MathTools.NormalVectorFromAzi(azi) * SpaceWarConfig.ShootEndDest, azi);
 }
Exemplo n.º 13
0
 void Warship_OnDead(WarShip sender)
 {
     //sceneMgr.DelGameObj(sender.MgPath);
     if (PurviewMgr.IsMainHost)
     {
         while (true)
         {
             Vector2 newPos = RandomHelper.GetRandomVector2(0, 1);
             newPos.X *= mapRect.Width;
             newPos.X += mapRect.X;
             newPos.Y *= mapRect.Height;
             newPos.Y += mapRect.Y;
             if (CanAddObjAtPos(newPos))
             {
                 (sender as WarShip).Born(newPos);
                 SyncCasheWriter.SubmitUserDefineInfo("WarshipBorn", "", sender, newPos);
                 break;
             }
         }
     }
 }
Exemplo n.º 14
0
        private void InitializeScene()
        {
            sceneMgr = new SceneMgr();

            sceneMgr.AddGroup("", new TypeGroup<WarShip>("warship"));
            sceneMgr.AddGroup("", new TypeGroup<WarShipShell>("shell"));
            sceneMgr.AddGroup("", new TypeGroup<SmartTank.PhiCol.Border>("border"));
            sceneMgr.AddGroup("", new TypeGroup<Gold>("gold"));
            sceneMgr.AddGroup("", new TypeGroup<Rock>("rock"));

            sceneMgr.PhiGroups.Add("warship");
            sceneMgr.PhiGroups.Add("shell");
            sceneMgr.PhiGroups.Add("rock");
            sceneMgr.AddColMulGroups("warship", "shell", "border");
            sceneMgr.AddColMulGroups("warship", "shell", "rock");
            sceneMgr.ColSinGroups.Add("warship");
            sceneMgr.ColSinGroups.Add("rock");

            sceneMgr.AddLapMulGroups("warship", "gold");

            ships = new WarShip[playerNames.Length];
            for (int i = 0; i < playerNames.Length; i++)
            {
                bool openControl = false;
                if (i == controlIndex)
                    openControl = true;

                ships[i] = new WarShip("ship" + i, new Vector2(400 + i * 800, 600), 0, openControl);
                ships[i].OnCollied += new OnCollidedEventHandler(WarShip_OnCollied);
                ships[i].OnOverLap += new OnCollidedEventHandler(Warship_OnOverLap);
                ships[i].OnShoot += new WarShip.WarShipShootEventHandler(WarShip_OnShoot);
                ships[i].OnDead += new WarShip.WarShipDeadEventHandler(Warship_OnDead);
                ships[i].PlayerName = playerNames[i];
                sceneMgr.AddGameObj("warship", ships[i]);
            }

            gold = new Gold("gold", new Vector2(800, 600), 0);
            gold.OnOverLap += new OnCollidedEventHandler(Gold_OnOverLap);
            gold.OnLiveTimeOut += new Gold.GoldLiveTimeOutEventHandler(Gold_OnLiveTimeOut);

            sceneMgr.AddGameObj("border", new SmartTank.PhiCol.Border(mapRect));
            sceneMgr.AddGameObj("gold", gold);

            GameManager.LoadScene(sceneMgr);

            camera.Focus(ships[controlIndex], false);
        }
Exemplo n.º 15
0
 private void SyncShipScoreHp(WarShip ship, bool subScore)
 {
     if (PurviewMgr.IsMainHost)
     {
         if (subScore)
             SyncCasheWriter.SubmitUserDefineInfo("Score", "", ship, ship.Score);
         else
             SyncCasheWriter.SubmitUserDefineInfo("Hp", "", ship, ship.HP);
     }
 }
Exemplo n.º 16
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++;
            }
        }