public List <Command> GetCommandsFromHost() { List <Command> cs = new List <Command>(); //if(cmdGameSet != null) //{ // cs.Add(cmdGameSet); //add GameSetCmd // cmdGameSet = null; //} //unitupdatecmd UnitUpdateCmd unitUpdateCmd = new UnitUpdateCmd(); unitUpdateCmd.units = units; cs.Add((Command)unitUpdateCmd); return(cs); }
void ProcessMyCommand() { for (int i = 0; i < commands.Count; i++) { Command c1 = commands[i]; if (c1 == null) { continue; } if (c1.processed) { continue; } if (c1 is GameSetCmd) { GameSetCmd c = (GameSetCmd)c1; openResultScene(c.isHostWin); } if (c1 is UnitMovedCmd) { UnitMovedCmd c = (UnitMovedCmd)c1; var basicUnit = GetBasicUnit(c.uuid); //Debug.Log(c.vx); if (basicUnit != null && !basicUnit.MovementLocked && !basicUnit.Locked) // lockdown and waittime check { Unit u = GetUnit(c.uuid); u.vx = c.vx; u.vz = c.vz; //schin Remove "ready to roll" emotion when ready. // this doesn't check if it's really moved for client basicUnit.ExpireEmotion(EmotionType.CD_READY); // Tinaxd update CountdownUI (Host only) // Generate a UnitTimerCommand if (isClient == 0) { UnitTimerCmd utc = new UnitTimerCmd(); utc.penalty = basicUnit.WaitTimePenaltyTime; utc.timerType = UnitTimerCmd.MOVED; utc.uuid = c.uuid; unitTimerRequests.Add(utc); commands.Add(utc); } } else { } c.processed = true; } if (c1 is UnitUpdateCmd) { UnitUpdateCmd c = (UnitUpdateCmd)c1; //Debug.Log(c.vx); if (isClient > 0) { //TODO if units.isDeadあり //UnitDied() units = c.units; } c.processed = true; c.sent = true; } if (c1 is UnitTimerCmd) { UnitTimerCmd c = (UnitTimerCmd)c1; switch (c.timerType) { case 0: // MOVED var basicUnit = GetBasicUnit(c.uuid); if (basicUnit != null) { basicUnit.MarkMoved(); } // Lockdown ends foreach (var instance in instances) { var bu = instance.basicUnit; if (bu == null) { continue; } if (bu.Owned != basicUnit.Owned) { bu.MovementLocked = false; } } break; case 1: // HOST LOCKDOWN foreach (var instance in instances) { var bu = instance.basicUnit; if (bu == null) { continue; } if (isClient > 0) { if (bu.Owned) { bu.MovementLocked = true; } else { bu.MarkLockdown(); } } else { if (bu.Owned) { bu.MarkLockdown(); } else { bu.MovementLocked = true; } } } break; case 2: // CLIENT LOCKDOWN foreach (var instance in instances) { var bu = instance.basicUnit; if (bu == null) { continue; } if (isClient > 0) { if (bu.Owned) { bu.MarkLockdown(); } else { bu.MovementLocked = true; } } else { if (bu.Owned) { bu.MovementLocked = true; } else { bu.MarkLockdown(); } } } break; } //TODO if c is GameSetCmd //SceneManager.LoadScene("Result"); //clientBattleScene, isHostWin = GameSetCmd.isHostWin if (isClient > 0 && (!AutoPlay.isOffline)) { c.processed = true; } } if (c1 is NewUnitCmd) { //Debug.Log(GetUnit(((NewUnitCmd)c1).fromUnitId).owner); NewUnitCmd c = (NewUnitCmd)c1; switch (c.unitType) { case 2: // Arrow { Unit u = GetUnit(c.fromUnitId); if (u == null) { break; } if (u.projectileReload <= 0) { u.projectileReload = 7; CreateArrow(GetUnit(c.fromUnitId), c.velocity); } } break; case 3: // Fireball { var u = GetUnit(c.fromUnitId); if (u.MP > 25) { u.MP -= 25; CreateFireball(u, c.velocity); } } break; } c.processed = true; } if (c1 is HealingBuffRequestCmd) { var c = (HealingBuffRequestCmd)c1; if (isClient == 0) { var requestor = GetUnit(c.RequestorId); var target = GetUnit(c.TargetId); if (PhysicsSimulator.UnitDistance1(requestor, target) < HealingBuffMaxDistance) { target.buff |= BuffFlag.BUFF_HEALING; } c.processed = true; } //GetBasicUnit(c.RequestorId).DragMode = DragType.NORMAL; //UnityEngine.EventSystems.ExecuteEvents.Execute<IDragAndFireEventHandler>(this.gameObject, null, (x, y) => x.TurnOnDrag()); } } List <Command> remains = new List <Command>(); for (int i = 0; i < commands.Count; i++) { if (commands[i].sent) { continue; } remains.Add(commands[i]); } commands = remains; }