public Arena.HitInfo Fire() { Arena arena = m_arena.GetComponent <Arena>(); Arena.HitInfo hit = arena.Trace(m_x_position, m_y_position, (m_orientation + m_turret_orientation) % 4); m_pro_dist = hit.distance; m_animation_state = 0.0f; m_status = Status.Firing; m_pro_obj = GameObject.CreatePrimitive(PrimitiveType.Sphere); m_pro_obj.transform.parent = gameObject.transform.Find("turret"); m_pro_obj.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f); m_pro_obj.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); return(hit); }
void FixedUpdate() { int currentStage = m_network.GetComponent <Network>().m_stage; switch (currentStage) { case 0: m_trade_button.gameObject.SetActive(true); m_transmit_button.gameObject.SetActive(false); break; case 2: m_trade_button.gameObject.SetActive(false); m_transmit_button.gameObject.SetActive(true); break; case 1: case 3: default: m_trade_button.gameObject.SetActive(false); m_transmit_button.gameObject.SetActive(false); break; } if (!m_game_running) { return; } for (int i = 0; i < m_players.Length; ++i) { Bot bot = m_players[i].bot.GetComponent <Bot>(); if (bot.GetStatus() == Bot.Status.Dead) { m_game_running = false; Invoke("RestartGame", 3.0f); m_network.GetComponent <Network>().leaveGame(); return; } } if (m_action_sequence.Count > 0) { Bot bot = m_players[m_action_player].bot.GetComponent <Bot>(); if (bot.GetStatus() == Bot.Status.Idle) { Action action = m_actions.GetAction(m_action_sequence.Pop()); if (action.passive.actions != null) { for (int i = action.passive.actions.Length - 1; i >= 0; --i) { m_action_sequence.Push(action.passive.actions[i]); } } if (action.passive.player_move != 0) { bot.Move(action.passive.player_move); } else if (action.passive.turn_body > 0) { bot.TurnRight(); } else if (action.passive.turn_body < 0) { bot.TurnLeft(); } else if (action.passive.turn_turret > 0) { bot.TurnTurretRight(); } else if (action.passive.turn_turret < 0) { bot.TurnTurretLeft(); } else if (action.passive.align_turret_to_body) { bot.AlignTurret(); } else if (action.passive.target_modifier != 0) { m_target_bot.Modifier(action.passive.target_modifier); } else if (action.passive.player_modifier != 0) { bot.Modifier(action.passive.player_modifier); } else if (action.passive.target_move != 0) { m_target_bot.ForcedMove(m_target_dir); } else if (action.name == "fire" || action.name == "vampiric_shot") { Arena.HitInfo hitinfo = bot.Fire(); if (hitinfo.hit) { m_target_bot = hitinfo.bot; if (action.on_hit.actions != null) { for (int i = action.on_hit.actions.Length - 1; i >= 0; --i) { m_action_sequence.Push(action.on_hit.actions[i]); } } } } } } else if (!m_arena_acted) { Bot bot = m_players[m_action_player].bot.GetComponent <Bot>(); if (bot.GetStatus() == Bot.Status.Idle) { m_arena_acted = true; Tiles.Tile tile = bot.GetTile(); if (tile.actions != null) { for (int i = tile.actions.Length - 1; i >= 0; --i) { m_action_sequence.Push(tile.actions[i]); } m_target_bot = bot; m_target_dir = bot.GetTileDir(); } } } else { Bot bot = m_players[m_action_player].bot.GetComponent <Bot>(); if (m_card_sequence.Count > 0 && bot.GetStatus() == Bot.Status.Idle) { Card card = m_cards.GetCard(m_card_sequence.Pop()); HandBehaviour player_hand = m_player_hand.GetComponent <HandBehaviour> (); HandBehaviour opponent_hand = m_opponent_hand.GetComponent <HandBehaviour> (); player_hand.SelectCard(card); opponent_hand.SelectCard(card); ActionSequence(m_player_sequence.Pop(), card.actions); } } }