Exemple #1
0
    private IEnumerator ShowHurtEffect(TeamDisplay targetTeam, float delayFrame)
    {
        yield return(new WaitForSeconds(FightServiceDef.FRAME_INTERVAL_TIME_F * delayFrame));

        ShipDisplay targetShip = targetTeam.GetHurtShip();

        if (targetTeam == null)
        {
            yield break;
        }
        if (AttackTrans_ == null)
        {
            yield break;
        }
        if (targetShip == null)
        {
            yield break;
        }
        Transform trans = targetShip.GetTransformByName(targetShip.GetHitPoint(AttackTrans_.position.x, SpellType_));

        if (trans == null)
        {
            trans = targetShip.Trans;
        }
        Global.ShowHurtEffect(trans, HurtEffect_, trans.position);
    }
 /// <summary>
 /// 获得旗舰的gameobject
 /// </summary>
 /// <returns></returns>
 public static GameObject GetCommanderShipObj()
 {
     if (Instance == null)
     {
         return(null);
     }
     foreach (var iter in Instance.PlayerTeamDisplayList)
     {
         if (iter.Value == null)
         {
             continue;
         }
         if (!iter.Value.IsCommanderShip())
         {
             continue;
         }
         ShipDisplay display = iter.Value.GetHurtShip();
         if (display == null)
         {
             continue;
         }
         return(display.gameObject);
     }
     return(null);
 }
Exemple #3
0
 private void SetCache(Transform attackTrans, ShipDisplay targetShip, Transform targetTrans, SpellType spellType, string bulletPath, Effect hurtEffect)
 {
     AttackTrans_ = attackTrans;
     TargetTrans_ = targetTrans;
     TargetShip_  = targetShip;
     SpellType_   = spellType;
     BulletPath_  = bulletPath;
     HurtEffect_  = hurtEffect;
 }
Exemple #4
0
    /**
     * Called on each game loop
     * We use it to detect mouse clicks when moving a
     */
    void Update()
    {
        // Detect left clicks only on planets
        if (Input.GetMouseButtonDown(0) && inTransferingFleetMouseState())
        {
            RaycastHit hit = findObjectsOnScreen(); //Will return Vector3(0,0,0) if nothing found
            if (!(hit.point.x == 0 &&
                  hit.point.y == 0 &&
                  hit.point.z == 0))
            {
                //If we hit a planet, we send the fleet there
                GameObject hitObject = hit.transform.gameObject;
                if (hitObject.tag == "Planet" && currentlySelectedPlanet != null)
                {
                    // Take the fleet at the currently selected planet, and move it to this planet
                    ShipDisplay      shipScript  = shipDisplay.GetComponent <ShipDisplay>();
                    GameObject       chosenFleet = shipScript.getChosenFleet();
                    MoveShipsCommand moveShips;
                    if (chosenFleet != null)
                    {
                        shipScript.clearChosenFleet();

                        moveShips = new MoveShipsCommand(
                            chosenFleet,
                            currentlySelectedPlanet,
                            hitObject,
                            CurrentPlayer.instance().getCurrentPlayerGameObject()
                            );
                    }
                    else
                    {
                        // TODO - Figure out how to handle selecting which fleet to go
                        GameObject currentFleet = currentlySelectedPlanet.GetComponent <Planet>().getFleetOverPlanet();
                        moveShips = new MoveShipsCommand(
                            currentFleet,
                            currentlySelectedPlanet,
                            hitObject,
                            CurrentPlayer.instance().getCurrentPlayerGameObject()
                            );
                    }
                    Player p = CurrentPlayer.instance().getCurrentPlayer();
                    p.addCommand(moveShips);
                    hitObject.GetComponent <Planet>().setTransferingFleet(true); // Don't show the player menu
                }
            }

            // Deactivate the moving fleet cursor regardless if we find something
            deactiveTargetMouse();
        }
        else if (Input.GetMouseButtonDown(1) && inTransferingFleetMouseState())
        {
            // Cancel moving the fleet if a right click is detected
            deactiveTargetMouse();
        }
    }
        private void GridViewItem_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            ShipDisplay ship = ((FrameworkElement)e.OriginalSource).DataContext as ShipDisplay;

            if (ship == null)
            {
                return;
            }

            //PilotSelector.ItemsSource = ship.Pilots;
            //PilotSelector.Visibility = Visibility.Visible;
            //ShipSelector.Visibility = Visibility.Collapsed;
        }
    public static TeamDisplay GetCommanderShipTeam()
    {
        GameObject ship = GetCommanderShipObj();

        if (ship == null)
        {
            return(null);
        }
        ShipDisplay display = ship.GetComponent <ShipDisplay>();

        if (display == null)
        {
            return(null);
        }
        return(display.GetTeam());
    }
Exemple #7
0
 private void SetCameraTarget(Transform trans)
 {
     if (trans == null)
     {
         CameraTargetTrans_ = trans;
     }
     else
     {
         ShipDisplay display = trans.GetComponent <ShipDisplay>();
         if (display == null)
         {
             return;
         }
         CameraTargetTrans_ = display.GetTeam().GetTeamGo().transform;
     }
 }
Exemple #8
0
    // change the current display to a different one
    public void ChangeDisplay(ShipDisplay newDisplay)
    {
        // Debug.Log( "Showing display " + newDisplay );

        // inactivate all of the display UI
        m_statusDisplay.Hide();
        m_systemDisplay.Hide();
        m_sensorsDisplay.Hide();
        m_terrainMapDisplay.Hide();
        m_terrainVehicleDisplay.Hide();

        // change the current display
        m_currentDisplay = newDisplay;

        // fire it up
        m_currentDisplay.Show();

        // update the display label
        m_displayLabel.text = m_currentDisplay.GetLabel();
    }
Exemple #9
0
    private static BulletDisplay InitBullet(Transform attackTrans, ShipDisplay targetShip, Transform targetTrans, SpellType spellType, string bulletPath, Effect hurtEffect)
    {
        GameObject bullet = AssetLoader.PlayEffect(bulletPath);

        if (bullet == null)
        {
            Debug.Log("can not find bullet:" + bulletPath);
            bullet = new GameObject();
            //return null;
        }
        bullet.name = spellType.ToString();
        bullet.transform.position = attackTrans.position;
        bullet.transform.rotation = attackTrans.rotation;
        BulletDisplay display = bullet.GetComponent <BulletDisplay>();

        if (display == null)
        {
            display = bullet.AddComponent <BulletDisplay>();
        }
        display.SetCache(attackTrans, targetShip, targetTrans, spellType, bulletPath, hurtEffect);
        return(display);
    }
 public async Task NavigateToPilotSelectionAsync(ShipDisplay ship)
 {
     await NavigationService.NavigateAsync(typeof(PilotSelectionPage), parameter : ship.ShipName);
 }
Exemple #11
0
    /// <summary>
    /// 子弹
    /// </summary>
    /// <param name="attackShipTrans"></param>
    /// <param name="attackPartTrans"></param>
    /// <param name="target"></param>
    /// <param name="attackPart"></param>
    /// <param name="part"></param>
    /// <param name="delayTime"></param>
    public static void ShowBullet(float srcX, Transform attackPartTrans, List <BulletTarget> targetList, ClientParts attackPart,
                                  SpellType spellType, string bulletPath, Effect hurtEffect, Vector3 position, ClientSkill skill)
    {
        // 范围攻击特殊处理
        if (spellType == SpellType.AOE)
        {
            BulletDisplay display = InitBullet(attackPartTrans, null, null, spellType, bulletPath, hurtEffect);
            if (display == null)
            {
                return;
            }
            display.SetAOE(targetList, position, skill);
            return;
        }

        // 其他攻击,一个子弹只对应一个目标
        if (targetList.Count != 1)
        {
            return;
        }

        if (targetList[0].Target == null)
        {
            return;
        }

        ShipDisplay targetShip = targetList[0].Target.GetHurtShip();

        if (targetShip == null)
        {
            return;
        }
        float delayTime = FightServiceDef.FRAME_INTERVAL_TIME_F * targetList[0].delayFrame;

        Transform targetTrans = targetShip.GetTransformByName(targetShip.GetHitPoint(srcX, spellType));

        if (targetTrans == null)
        {
            targetTrans = targetShip.Trans;
        }

        // 导弹特殊处理,从左右发子弹
        if (spellType == SpellType.Missile)
        {
            // TODO: 临时增加逻辑,防御节点一边扔3颗导弹
            // 后面要考虑走配置
            int missileCout = 1;
            if (attackPart.Owner.Reference.unitstrait == Def.ShipTrait.DefenseBuild)
            {
                missileCout = 3;
            }
            for (int i = 0; i < missileCout; i++)
            {
                BulletDisplay display = InitBullet(attackPartTrans, targetShip, targetTrans, spellType, bulletPath, hurtEffect);
                if (display == null)
                {
                    return;
                }
                display.SetMissile(attackPartTrans.name.Contains("left"), delayTime);
            }
        }
        // 机枪特殊处理,做成扫射效果
        else if (spellType == SpellType.MachineGun)
        {
            for (int i = 0; i < attackPart.Reference.continuity_times; i++)
            {
                BulletDisplay display = InitBullet(attackPartTrans, targetShip, targetTrans, spellType, bulletPath, hurtEffect);
                display.SetGun(delayTime, (float)attackPart.Reference.continuity_interval / 1000f * i);
            }
        }
        else
        {
            BulletDisplay display = InitBullet(attackPartTrans, targetShip, targetTrans, spellType, bulletPath, hurtEffect);
            display.SetLaserOrConnon(delayTime);
        }
    }
Exemple #12
0
    private IEnumerator ShipFireIE(ShipDisplay display, proto.PartFireEvent fireEvent)
    {
        yield return(new WaitForSeconds(Random.Range(0f, 1f)));

        display.ShipFire(fireEvent);
    }
Exemple #13
0
    public void Init(ClientShip clientShip, Ship ship, List <GameObject> shipList, bool bPlayer)
    {
        IsDead = false;

        RootGo_ = new GameObject("Root_" + (bPlayer ? "Player" : "Enemy") + "_");  //+ clientShip.Reference.name );
        RootGo_.transform.position = clientShip.Position;

        ClientShip_ = clientShip;
        //Ship_ = ship;
        Vector3[] tempFormationList = clientShip.FormationList;

        for (int i = 0; i < shipList.Count; i++)
        {
            ShipDisplay display = shipList[i].AddComponent <ShipDisplay>();
            display.Init(this, ship, clientShip.Position, tempFormationList == null ? Vector3.zero : tempFormationList[i], bPlayer);
            ShipList_.Add(display);
        }
        bool isAdvancedShip = (clientShip.Reference.id == 40000 || clientShip.Reference.id == 60000);//暂时这样写,到时候根据tag来

        BattleShipInfo_ = BattleShipInfo.Create(RootGo_.transform, this, clientShip.Name, ship.shieldRadius, bPlayer, isAdvancedShip);

        foreach (var iter in clientShip.PartsList)
        {
            float atkRangeMin  = iter.Reference.atk_range_min;
            float atkRangeMax  = iter.Reference.atk_range_max;
            float atkMoveRange = iter.Reference.attack_move_range;
            float angle        = iter.Reference.atk_angle;
            // 最近和最远的攻击范围
            AttackRangeDisplayList_.Add(AttackRangeDisplay.InitSectorAttackRange(bPlayer, RootGo_.transform, atkRangeMin, atkRangeMax, angle, Color.red));
            // 移动攻击范围
            AttackRangeDisplayList_.Add(AttackRangeDisplay.InitSectorAttackRange(bPlayer, RootGo_.transform, 0, atkMoveRange, angle, Color.gray));
        }

        // 是玩家并且是旗舰,生成技能范围
        if (bPlayer && clientShip.IsCommanderShip())
        {
            for (int i = 0; i < 3; i++)
            {
                ClientSkill        skill   = clientShip.GetSkillByIndex(i);
                AttackRangeDisplay display = null;
                if (skill != null)
                {
                    proto.SkillReference reference = skill.Prop;
                    // 扇形
                    if (reference.skill_select_type == Def.SkillSelectType.CastScope)
                    {
                        display = AttackRangeDisplay.InitSectorAttackRange(true, RootGo_.transform, 0, reference.cast_range, reference.cast_angle, Color.blue);
                    }
                    //else if( reference.skill_select_type == Def.SkillSelectType.PlayerSelect ) {
                    // 圆形
                    //if( reference.shape_type == Def.ShapeType.Circle ) {
                    //    display = AttackRangeDisplay.InitCircleAttackRange( RootGo_.transform, reference.aoe_range, Color.blue );
                    //}
                    //}
                    else if (reference.skill_select_type == Def.SkillSelectType.NoSelection)
                    {
                        // 矩形或圆形
                        if (reference.shape_type == Def.ShapeType.Rectangle)
                        {
                            display = AttackRangeDisplay.InitRectangleAttackRange(RootGo_.transform, reference.radiate_len, reference.radiate_wid * 2, Color.blue);
                        }
                        else if (reference.shape_type == Def.ShapeType.Circle)
                        {
                            display = AttackRangeDisplay.InitCircleAttackRange(RootGo_.transform, reference.aoe_range, Color.blue);
                        }
                    }
                    if (display != null)
                    {
                        display.gameObject.name += "_skill";
                    }
                }
                SkillAttackRangeDisplayList.Add(display);
            }
        }

        if (HaloTemplate_ == null)
        {
            HaloTemplate_ = Resources.Load("Effect/Halo");
        }

        HaloGo_ = GameObject.Instantiate(HaloTemplate_) as GameObject;
        HaloGo_.transform.GetChild(0).localPosition = Vector3.zero;
        HaloGo_.transform.parent           = RootGo_.transform;
        HaloGo_.transform.localEulerAngles = Vector3.zero;
        HaloGo_.transform.localPosition    = Vector3.zero + new Vector3(0, -1, 0);
        HaloGo_.transform.localScale       = Vector3.one * clientShip.Reference.vol;
    }