コード例 #1
0
    public void TryAttack()
    {
        if (Time.time < m_NextAttackTime)
        {
            return;
        }

        m_NextAttackTime = Time.time + m_AttackInterval;

        DemoSF_GameEntry.Entity.ShowEntity <DemoSF_Bullet>(
            DemoSF_EntityExtension.GenerateSerialId(),
            "Assets/DemoStarForce/Prefabs/PlayerBolt.prefab",
            "BulletGroup",
            CachedTransform.position);
    }
コード例 #2
0
    public void Initialize()
    {
        DemoSF_GameEntry.Event.Subscribe(ShowEntitySuccessEventArgs.EventId, OnShowEntitySuccess);
        DemoSF_GameEntry.Event.Subscribe(ShowEntityFailureEventArgs.EventId, OnShowEntityFailure);

        m_SceneBackground = Object.FindObjectOfType <DemoSF_ScrollableBackground>();

        // 创建实体
        DemoSF_GameEntry.Entity.ShowEntity <DemoSF_Aircraft>(
            DemoSF_EntityExtension.GenerateSerialId(),
            "Assets/DemoStarForce/Prefabs/PlayerShip.prefab",
            "PlayerGroup");

        GameOver     = false;
        m_MyAircraft = null;
    }
コード例 #3
0
    protected override void OnShow(object userData)
    {
        base.OnShow(userData);

        CachedTransform.localPosition = transform.position;
        CachedTransform.localRotation = transform.rotation;
        CachedTransform.localScale    = Vector3.one;

        // 移动范围
        DemoSF_ScrollableBackground sceneBackground = FindObjectOfType <DemoSF_ScrollableBackground> ();

        m_PlayerMoveBoundary = new Rect(sceneBackground.PlayerMoveBoundary.bounds.min.x, sceneBackground.PlayerMoveBoundary.bounds.min.z,
                                        sceneBackground.PlayerMoveBoundary.bounds.size.x, sceneBackground.PlayerMoveBoundary.bounds.size.z);

        // 加载武器,最后一个参数为当前飞机的ID,武器将附加到飞机身上
        DemoSF_GameEntry.Entity.ShowEntity <DemoSF_Weapon>(
            DemoSF_EntityExtension.GenerateSerialId(),
            "Assets/DemoStarForce/Prefabs/DefaultWeapon.prefab",
            "WeaponGroup",
            this.Entity.Id.ToString());
    }
コード例 #4
0
    public void Update(float elapseSeconds, float realElapseSeconds)
    {
        if (m_MyAircraft != null && m_MyAircraft.IsDead)
        {
            GameOver = true;
            return;
        }

        m_ElapseSeconds += elapseSeconds;
        if (m_ElapseSeconds >= 1f)
        {
            m_ElapseSeconds = 0f;

            float randomPositionX = m_SceneBackground.EnemySpawnBoundary.bounds.min.x + m_SceneBackground.EnemySpawnBoundary.bounds.size.x * (float)Utility.Random.GetRandomDouble();
            float randomPositionZ = m_SceneBackground.EnemySpawnBoundary.bounds.min.z + m_SceneBackground.EnemySpawnBoundary.bounds.size.z * (float)Utility.Random.GetRandomDouble();

            DemoSF_GameEntry.Entity.ShowEntity <DemoSF_Asteroid>(
                DemoSF_EntityExtension.GenerateSerialId(),
                "Assets/DemoStarForce/Prefabs/Asteroid01.prefab",
                "AsteroidGroup",
                new Vector3(randomPositionX, 0f, randomPositionZ));
        }
    }