Inheritance: MonoBehaviour, IDamageable
コード例 #1
0
 public NewIdleState(NewEnemy enemy, string id, float stayTime, string transition) : base(id)
 {
     _enemy       = enemy;
     _stayTime    = stayTime;
     _transition  = transition;
     _currentTime = 0;
 }
コード例 #2
0
    protected override void OnCollisionEnter2D(Collision2D collision)
    {
        NewEnemy enemy = collision.gameObject.GetComponent <NewEnemy>();

        if (enemy != null && enemy.hit(1))
        {
            Destroy(gameObject, 0f);
            Player.countLaser--;
        }
    }
コード例 #3
0
ファイル: GunController.cs プロジェクト: Raid-51/Raid-51
    void Update()
    {
        // Þetta er til þess að keyra CustomStart þegar það er búið að skipta um scene
        if (cam == null)
        {
            CustomStart();
        }

        AmmoTextAmount.text = Ammo + "/10";

        if (INV.CurrentItemID() == 3) //Ef spilarinn er ða halda á byssu
        {
            //Setur texta sem segir manni hvað maður er með mikið ammo, og breytir crosshair-inu
            Crosshair.SetActive(true);
            AmmoText.SetActive(true);

            if (Input.GetMouseButtonDown(0) && Ammo > 0)
            {
                Ammo -= 1;

                RaycastHit hit;
                Ray        ray = playerCamera.ScreenPointToRay(Input.mousePosition); //Skýtur raycast í miðju skjáar

                if (Physics.Raycast(ray, out hit, 20, Mask))
                {
                    //Ef það hittir óvin
                    if (hit.collider.tag == "Enemy")
                    {
                        print("Owch");

                        GameObject enemyHit       = hit.collider.gameObject;
                        NewEnemy   enemyHitScript = enemyHit.GetComponent <NewEnemy>();

                        enemyHitScript.Health -= gunDamage; //Tekur líf af enemy-inum

                        // Tékka hvort að óvinurinn eigi að deyja
                        if (enemyHitScript.Health <= 0)
                        {
                            enemyHitScript.Dead();
                        }
                        else
                        {
                            enemyHitScript.ChasePlayer();
                        }
                    }
                }
            }
        }
        else //Felur ammotexta og crosshair-inu
        {
            Crosshair.SetActive(false);
            AmmoText.SetActive(false);
        }
    }
コード例 #4
0
    public async Task <Item> Create([FromBody] NewEnemy enemy)
    {
        Enemy new_enemy = new Enemy();

        new_enemy.Id     = Guid.NewGuid();
        new_enemy.Name   = enemy.Name;
        new_enemy.Level  = enemy.Level;
        new_enemy.Damage = enemy.Level * 3;
        new_enemy.Hp     = enemy.Level * enemy.Level * 2;
        await _irepository.CreateEnemy(new_enemy);

        return(null);
    }
コード例 #5
0
        private void AddNinja()
        {
            // Create the animation object
            Animation ninjaAnimation = new Animation();

            // Initialize the animation with the correct animation information
            ninjaAnimation.Initialize(ninjaTexture, Vector2.Zero, 80, 67, 11, 45, Color.White, 1f, true);

            // Randomly generate the position of the enemy
            Vector2 position = new Vector2(GraphicsDevice.Viewport.Width + ninjaTexture.Width / 2, random.Next(100, GraphicsDevice.Viewport.Height - 100));

            // Create an enemy
            NewEnemy ninja = new NewEnemy();

            // Initialize the enemy
            ninja.Initialize(ninjaAnimation, position);

            // Add the enemy to the active enemies list
            ninjas.Add(ninja);
        }
コード例 #6
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        NewEnemy enemy = collision.gameObject.GetComponent <NewEnemy>();

        if (enemy != null && enemy.hit(3))
        {
            // return;
            health--;
            if (health <= 0)
            {
                health = 3;
                life--;
                player.stateMachine.currentState = player.destroyState;
            }
            else
            {
                transform.position = Vector3.zero;
            }
        }
    }
コード例 #7
0
 public Ram(NewEnemy enemy) : base(enemy)
 {
 }
コード例 #8
0
 public Move(NewEnemy enemy) : base(enemy)
 {
 }
コード例 #9
0
 public EnemyState(NewEnemy enemy)
 {
     this.enemy = enemy;
 }
コード例 #10
0
 public Wait(NewEnemy enemy) : base(enemy)
 {
 }
コード例 #11
0
 public Destroyed(NewEnemy enemy, float rm = 1) : base(enemy)
 {
     rotationMultiplier = rm;
 }
コード例 #12
0
 public AttackIdleState(NewEnemy enemy, string id) : base(id)
 {
     _enemy = enemy;
 }
コード例 #13
0
 public NewAttackState(NewEnemy enemy, string id) : base(id)
 {
     _enemy = enemy;
 }
コード例 #14
0
ファイル: MoveState.cs プロジェクト: taekong423/GgumGate
 public NewMoveState(NewEnemy enemy, string id, string transition) : base(id)
 {
     _enemy      = enemy;
     _transition = transition;
 }
コード例 #15
0
ファイル: ChaseState.cs プロジェクト: taekong423/GgumGate
 public NewChaseState(NewEnemy enemy, string id) : base(id)
 {
     _enemy = enemy;
 }
コード例 #16
0
ファイル: SwitchSceneManager.cs プロジェクト: Raid-51/Raid-51
    void CustomStart()
    {
        cam = Camera.main;
        Scene scene = SceneManager.GetActiveScene();


        /* ==================================================
        *  ==========       Pickupable Items       ==========
        *  ================================================== */
        // Bæta öllum pickupable hlutunum í AllPickups listann ef það er ekki búið að bæta objectunum í þessu scene í listann, annars eyðir þetta öllum pickupable hlutunum
        if (!CollectedItemsFromScene.Contains(scene.buildIndex))
        {
            // Passa að það verði ekki bætt hlutunum úr þessu scene-i í AllPickups aftur
            CollectedItemsFromScene.Add(scene.buildIndex);

            // Bæta öllum hlutunum með tagið Object við í AllPickups listann og passa að þeim verði ekki eytt þegar það er skipt um scene.
            foreach (GameObject Pickup in GameObject.FindGameObjectsWithTag("Object"))
            {
                // Þetta gerist bara ef hluturinn er ekki í Don't Destroy On Load núþegar
                if (Pickup.scene.buildIndex != -1)
                {
                    AllPickups.Add(Pickup);
                    DontDestroyOnLoad(Pickup);
                }
            }
        }
        else
        {
            foreach (GameObject Pickup in GameObject.FindGameObjectsWithTag("Object"))
            {
                if (Pickup.scene.buildIndex != -1)
                {
                    Destroy(Pickup);
                }
            }
        }
        // Eyða öllum pickupable hlutunum sem byrjuðu í sceninu en eiga ekki að vera lengur því að leikurinn er núþegar að geyma þá
        foreach (GameObject Pickupable in GameObject.FindGameObjectsWithTag("Object"))
        {
            if (!AllPickups.Contains(Pickupable))
            {
                Destroy(Pickupable);
            }
        }
        // Slökkva og kveikja á pickupable objectum eftir því í hvaða sceni þeir eiga að vera
        foreach (GameObject Pickupable in AllPickups)
        {
            // Ef hluturinn segir að hann eigi að vera í þessu scenei þá er hann activataður, annars er hann deactivataður
            if (Pickupable.GetComponent <Object>().SceneNumber == scene.buildIndex)
            {
                // Færa hlutinn aðeins upp svo að hann detti ekki í gegnum terrainið
                Vector3 location = Pickupable.transform.position;
                location.y += 0.05f;
                Pickupable.transform.position = location;

                // Activata hlutinn aftur
                Pickupable.SetActive(true);
            }
            else
            {
                Pickupable.SetActive(false);
            }
        }


        /* ==================================================
        *  ==========         Player stats         ==========
        *  ================================================== */
        // Finna spilarann til þess að gefa honum rétt líf og stamina og líka til þess að mögulega hreyfa hann
        Player player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();

        // Gefa spilaranum rétt líf og stamina
        player.Health  = LastSceneHealth;
        player.Stamina = LastSceneStamina;
        // Gefa spilaranum réttu hlutina í höndina
        Hand playerHand = player.gameObject.GetComponent <Hand>();

        if (Slot1ItemID != -1)
        {
            playerHand.AddItem(Slot1ItemID, 1);
        }
        if (Slot2ItemID != -1)
        {
            playerHand.AddItem(Slot2ItemID, 2);
        }
        if (Slot3ItemID != -1)
        {
            playerHand.AddItem(Slot3ItemID, 3);
        }
        // Teleporta spilaranum á staðinn sem er í NextSpawnLocationName ef það er eitthvað í NextSpawnLocationName
        if (NextSpawnLocationName != "")
        {
            Debug.Log("NextSpawnLocationName: " + NextSpawnLocationName);
            Transform playerTransform   = player.gameObject.GetComponent <Transform>();
            Transform teleportTransform = GameObject.Find(NextSpawnLocationName).GetComponent <Transform>();
            playerTransform.position = teleportTransform.position;
            playerTransform.rotation = teleportTransform.rotation;
        }


        /* ==================================================
        *  ==========  Spilarinn kemur úr bunker   ==========
        *  ================================================== */
        if (NextSpawnLocationName != "")
        {
            // Loka bunkerunum sem spilarinn er að fara útúr ef það eru engar geimverur þar lengur
            if (NextSpawnLocationName.Substring(0, 6) == "Bunker")
            {
                // Ef það var ekki ófrelsuð geimvera í síðustu senu læsist hurðin
                if (AlienInLastScene == false)
                {
                    AllClosedDoors.Add(GetBunkerNumber(NextSpawnLocationName));// Loka hurðinni
                }
                else
                {
                    AlienInLastScene = false;
                }

                // Disablea óbvini sem eiga ekki að spawna þegar spilarinn er að koma úr bunker
                foreach (GameObject enemyGameObject in GameObject.FindGameObjectsWithTag("Enemy"))
                {
                    NewEnemy enemyScript = enemyGameObject.GetComponent <NewEnemy>();
                    if (enemyScript.noSpawnOnBunkerExit)
                    {
                        enemyGameObject.SetActive(false);
                    }
                }

                // Opna hliðið ef spilarinn er að koma úr bunker
                GameObject.FindGameObjectWithTag("Breakable fence").GetComponent <Breakable_fence>().destroyed = true;
            }
        }


        // Loka öllum hurðum sem eru í AllClosedDoors listanum ef spilarinn er í eyðimörkinni
        if (scene.buildIndex == 0)
        {
            foreach (GameObject SSDGameObject in GameObject.FindGameObjectsWithTag("SwitchSceneDoor"))
            {
                SwitchSceneDoor SSD      = SSDGameObject.GetComponent <SwitchSceneDoor>();
                GameObject      teleport = SSDGameObject.transform.GetChild(0).gameObject;

                // Ef þessi hurð teleportar úr bunker er henni lokuð ef hún er líka í AllClosedDoors listanum
                if (teleport.name.Substring(0, 6) == "Bunker")
                {
                    // Ef þessi bunker er í AllClosedDoors listanum
                    if (AllClosedDoors.IndexOf(GetBunkerNumber(teleport.name)) != -1)
                    {
                        // Loka hurðinni
                        SSD.CloseDoor();
                    }
                }
            }
        }


        // Hreinsa NextSpawnLocationName
        NextSpawnLocationName = "";
    }
コード例 #17
0
 public CinematicState(NewEnemy enemy, string id) : base(id)
 {
     _enemy = enemy;
     _gm    = GameObject.Find("GameManager").GetComponent <GameManager>();
 }