Exemplo n.º 1
0
    void Start()
    {
        gameparam = GameObject.FindGameObjectWithTag("gamemanager").GetComponent <GameParam>();

        player  = GameObject.FindGameObjectWithTag("Player");
        _player = player.GetComponent <Player>();

        StartCoroutine("UpdatePosition");

        if (!gameparam.UsingItem2)
        {
            DirectionVector = _player.firstPosition - transform.position;
        }
        else
        {
            player          = GameObject.FindGameObjectWithTag("FakePlayer");
            _fakeplayer     = player.GetComponent <FakePlayer> ();
            DirectionVector = _fakeplayer.firstPosition - transform.position;
        }


        float Enemyspeed = 1.0f;

        float DirectionSize = Mathf.Sqrt(DirectionVector.x * DirectionVector.x + DirectionVector.y * DirectionVector.y);

        DirectionVector = DirectionVector / DirectionSize * Enemyspeed;

        if (transform.position.y < -4.8f)
        {
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 2
0
        public void RunOnZoningStopsPlayerFromRunning()
        {
            // Fixture setup
            var api    = new FakeMemoryAPI();
            var player = new FakePlayer
            {
                Zone  = Zone.Konschtat_Highlands,
                Stats = new Structures.PlayerStats {
                    Str = 100
                }
            };

            var navigation = new Mock <INavigatorTools>();

            navigation.Setup(x => x.Reset());
            api.Player    = player;
            api.Navigator = navigation.Object;
            var sut = new ZoneState(api);

            player.Zone = Zone.Valkurm_Dunes;

            // Exercise system
            sut.Run();

            // Verify outcome
            navigation.Verify(x => x.Reset(), Times.Once());

            // Teardown
        }
Exemplo n.º 3
0
        public void RunOnZoningSetsZoneToNewZone()
        {
            // Fixture setup
            var api    = new FakeMemoryAPI();
            var player = new FakePlayer
            {
                Zone  = Zone.Konschtat_Highlands,
                Stats = new Structures.PlayerStats {
                    Str = 100
                }
            };

            var navigation = new Mock <INavigatorTools>();

            api.Player    = player;
            api.Navigator = navigation.Object;
            var sut = new ZoneState(api);

            player.Zone = Zone.Valkurm_Dunes;

            // Exercise system
            sut.Run();

            // Verify outcome
            Assert.Equal(Zone.Valkurm_Dunes, sut.Zone);

            // Teardown
        }
Exemplo n.º 4
0
    private void SpawnPlayer(int a_id, int a_inputdir = 0)
    {
        GameObject gameObject = (GameObject)Object.Instantiate(position: new Vector3(Random.Range((0f - m_radius) * 0.8f, m_radius * 0.8f), 1f, Random.Range((0f - m_radius) * 0.8f, m_radius * 0.8f)), original: m_playerPrefab, rotation: Quaternion.identity);
        FakePlayer component  = gameObject.GetComponent <FakePlayer>();

        component.m_id = a_id;
        component.SetInput(a_inputdir);
    }
Exemplo n.º 5
0
    private void SpawnPlayer(int a_id, int a_inputdir = 0)
    {
        Vector3    position   = new Vector3(UnityEngine.Random.Range(-this.m_radius * 0.8f, this.m_radius * 0.8f), 1f, UnityEngine.Random.Range(-this.m_radius * 0.8f, this.m_radius * 0.8f));
        GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(this.m_playerPrefab, position, Quaternion.identity);
        FakePlayer component  = gameObject.GetComponent <FakePlayer>();

        component.m_id = a_id;
        component.SetInput(a_inputdir);
    }
Exemplo n.º 6
0
        private Executor CreateSut(FakeWindower windower, FakePlayer player)
        {
            var memory = new FakeMemoryAPI();

            memory.Player   = player;
            memory.Windower = windower;

            var sut = new Executor(memory);

            return(sut);
        }
Exemplo n.º 7
0
            private static BattleState CreateSut(FakeWindower windower, FakePlayer player)
            {
                var navigator = FindNavigator();

                var sut = new BattleState(new FakeMemoryAPI()
                {
                    Windower  = windower,
                    Player    = player,
                    Navigator = navigator
                });

                return(sut);
            }
Exemplo n.º 8
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        FakePlayer myTarget = (FakePlayer)target;

        if (GUILayout.Button("Run Me"))
        {
            ((FakePlayer)target).RunMe();
        }

        if (GUILayout.Button("Continue"))
        {
            ((FakePlayer)target).Continue();
        }
    }
Exemplo n.º 9
0
        public void CraftItem_RecipeIsComplete_AThousandTimes_()
        {
            var player      = new FakePlayer();
            var repetitions = 1000;

            Stopwatch sw = Stopwatch.StartNew();

            for (int index = 0; index < repetitions; index++)
            {
                player.CraftItem(itemToCraftID);
            }
            var duration = sw.ElapsedMilliseconds;

            sw.Stop();
            Assert.Warn($"{repetitions} executions of GamePlayer.CraftItem took {duration} ms.");
        }
Exemplo n.º 10
0
        private Executor CreateSut(
            FakeWindower windower,
            FakePlayer player,
            FakeNavigator navigator,
            FakeTarget target)
        {
            var memory = new FakeMemoryAPI();

            memory.Player    = player;
            memory.Windower  = windower;
            memory.Navigator = navigator;
            memory.Target    = target;

            var sut = new Executor(memory);

            return(sut);
        }
Exemplo n.º 11
0
        public void RunWhileZoningWaits()
        {
            // Fixture setup
            var api    = new FakeMemoryAPI();
            var player = new FakePlayer
            {
                Zone  = Zone.Konschtat_Highlands,
                Stats = new Structures.PlayerStats {
                    Str = 0
                }
            };

            var navigation = new Mock <INavigatorTools>();

            navigation.Setup(x => x.Reset());
            api.Player    = player;
            api.Navigator = navigation.Object;
            var sut = new ZoneState(api)
            {
                ZoningAction = () =>
                {
                    player.Stats = new Structures.PlayerStats
                    {
                        Str = 100
                    };
                }
            };

            player.Zone = Zone.Valkurm_Dunes;

            // Exercise system
            sut.Run();

            // Verify outcome
            Assert.Equal(100, player.Stats.Str);

            // Teardown
        }
Exemplo n.º 12
0
        public void CheckIsTrueWhenPlayersStatsAreZero()
        {
            // Fixture setup
            var api    = new FakeMemoryAPI();
            var player = new FakePlayer
            {
                Zone  = Zone.Konschtat_Highlands,
                Stats = new Structures.PlayerStats {
                    Str = 0
                }
            };

            api.Player = player;
            var sut = new ZoneState(new StateMemory(api));

            // Exercise system
            var result = sut.Check();

            // Verify outcome
            Assert.True(result);

            // Teardown
        }
Exemplo n.º 13
0
        public void CheckIsFalseWhenNotZoning()
        {
            // Fixture setup
            var api    = new FakeMemoryAPI();
            var player = new FakePlayer
            {
                Zone  = Zone.Konschtat_Highlands,
                Stats = new Structures.PlayerStats {
                    Str = 100
                }
            };

            api.Player = player;
            var sut = new ZoneState(api);;

            // Exercise system
            var result = sut.Check();

            // Verify outcome
            Assert.False(result);

            // Teardown
        }
Exemplo n.º 14
0
    void ExplodeGrenade()
    {
        GameObject particle = Instantiate(particleEffect, transform.position, Quaternion.identity);

        Collider[] colliders = Physics.OverlapSphere(transform.position, radius);

        foreach (Collider nearObjects in colliders)
        {
            Rigidbody rb = nearObjects.GetComponent <Rigidbody>();

            FakePlayer victimPlayer = nearObjects.gameObject.GetComponent <FakePlayer>();

            if (grenade == GrenadeStates.impact)
            {
                Impact(rb);
            }
            if (grenade == GrenadeStates.damage)
            {
                if (victimPlayer != null)
                {
                    float distance = (transform.position - nearObjects.transform.position).magnitude;

                    victimPlayer.health -= (maxDamage * (1 / distance));

                    Impact(rb);
                }
            }
            if (grenade == GrenadeStates.time)
            {
                GameObject timeField = Instantiate(timeFieldObj, transform.position, transform.rotation);
            }
        }

        Object.Destroy(particle, 1);
        Destroy(gameObject);
        hasExploded = true;
    }
Exemplo n.º 15
0
        protected override void OnUpdate()
        {
            var entities = m_NetworkConnection.GetEntityArraySt();

            for (int i = 0; i < entities.Length; ++i)
            {
                var ent = entities[i];

                if (!EntityManager.HasComponent <NetworkStreamInGame>(ent))
                {
                    EntityManager.AddComponentData(ent, new NetworkStreamInGame());
                }

                if (!EntityManager.HasComponent <PlayerCommandData>(ent))
                {
                    EntityManager.AddBuffer <PlayerCommandData>(ent);
                    var ctc = EntityManager.GetComponentData <CommandTargetComponent>(ent);
                    ctc.targetEntity = ent;
                    EntityManager.SetComponentData(ent, ctc);
                }

                FakePlayer.PrepareFakePlayerIfNeeded();

                var cmdBuf = EntityManager.GetBuffer <PlayerCommandData>(ent);
                PlayerCommandData inputData;
                cmdBuf.GetDataAtTick(m_ServerSimulationSystemGroup.ServerTick, out inputData);
                if (inputData.grenade != 0)
                {
                    Debug.Log("LZ: Receive Grenade #" + inputData.grenade);

                    if (FakePlayer.m_HeadTr)
                    {
                        NetCodeIntegration.GrenadeManager.CreateGrenade(FakePlayer.m_HeadTr);
                    }
                }
            }
        }
Exemplo n.º 16
0
        public void CheckIsTrueWhenZoneChanges()
        {
            // Fixture setup
            var api    = new FakeMemoryAPI();
            var player = new FakePlayer {
                Zone = Zone.Konschtat_Highlands
            };

            api.Player = player;
            var sut = new ZoneState(api);

            player.Zone  = Zone.Valkurm_Dunes;
            player.Stats = new Structures.PlayerStats {
                Str = 100
            };

            // Exercise system
            var result = sut.Check();

            // Verify outcome
            Assert.True(result);

            // Teardown
        }
Exemplo n.º 17
0
 private void Awake()
 {
     instance = this;
     keys     = 0;
 }