Example #1
0
    void Burning()
    {
        Collider[] objects = Physics.OverlapBox(transform.position, halfSize, transform.rotation, layer);
        
        foreach (Collider objectsBurning in objects)
        {
            if (objectsBurning.tag == "Object" | objectsBurning.tag == "Enemy")
            {
                Fireable fireable = objectsBurning.GetComponent<Fireable>();

                if (objectsBurning.tag == "Enemy")
                {
                    EnemyTest enemy = objectsBurning.GetComponent<EnemyTest>();

                    if (enemy.dead)
                    {
                        return;
                    }
                }

                if (fireable != null)
                {
                    fireable.timeCounter += Time.deltaTime;
                }
            }
        }
    }
Example #2
0
        /// <summary>
        /// Start is called on the frame when a script is enabled just before
        /// any of the Update methods is called the first time.
        /// </summary>
        private void Start()
        {
            if (DanmakuType == null)
            {
                Debug.LogWarning($"Emitter doesn't have a valid DanmakuPrefab", this);
                return;
            }

            var set = CreateSet(DanmakuType);

            set.AddModifiers(GetComponents <IDanmakuModifier> ());

            if (Fireables == null || Fireables.Count == 0)
            {
                Debug.LogWarning("Emitter doesn't have a valid Fireables", this);
                return;
            }

            _fireable = Fireables[0];
            for (int i = 1; i < Fireables.Count; i++)
            {
                _fireable = _fireable.Of(Fireables[i]);
            }
            _fireable.Of(set);
        }
Example #3
0
    void DetectOnFire()
    {
        Collider[] enemiesInArea = Physics.OverlapBox(transform.position, halfAreaSize, transform.rotation, layer);

        foreach (Collider nearbyObjects in enemiesInArea)
        {
            if (nearbyObjects.tag == ("Enemy"))
            {
                Fireable toFire = nearbyObjects.GetComponent <Fireable>();

                if (toFire != null)
                {
                    toFire.timeCounter += flameRate;
                }
            }
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        // Pause menu
        if (Input.GetKeyDown(StartButton))
        {
            GameManager.instance.pauseMenu.Toggle();
        }
        if (Game.Paused())
        {
            float lsVert = GetAxis("Vertical");
            if (!ls_pressed && Mathf.Abs(lsVert) > lsPressThreshold)
            {
                ls_pressed = true;
                if (lsVert > 0f)
                {
                }
                else
                {
                }
            }
            return;
        }

        if (allInputDisabled)
        {
            return;
        }

        //aiming and firing
        Vector2 aim_raw = new Vector2(0, 0);

        if (playerNum == keyboardControlledPlayer)
        {
            if (Input.GetKey(KeyCode.I))
            {
                aim_raw.y += 1;
            }
            if (Input.GetKey(KeyCode.K))
            {
                aim_raw.y -= 1;
            }
            if (Input.GetKey(KeyCode.J))
            {
                aim_raw.x -= 1;
            }
            if (Input.GetKey(KeyCode.L))
            {
                aim_raw.x += 1;
            }
        }
        if (aim_raw == new Vector2(0, 0))
        {
            aim_raw = new Vector2(GetAxis("Horizontal_R"), GetAxis("Vertical_R"));
        }
        aim_raw = Vector2.ClampMagnitude(aim_raw, 1.0f);
        if (aim_raw.sqrMagnitude < epsilon)
        {
            aim_raw = Vector2.zero;
            aimIndicator.GetComponent <SpriteRenderer>().enabled = false;
        }
        else if (!inventory.Get() || inventory.Get().GetComponent <Fireable>())
        {
            aimIndicator.GetComponent <SpriteRenderer>().enabled = true;
        }


        Vector2 aim = aim_raw.normalized;

        bool keyboardFire = false;

        if (playerNum == keyboardControlledPlayer)
        {
            keyboardFire = Input.GetKeyDown(KeyCode.Space);
        }
        float trigger = GetAxis("RTrigger");

        if ((!rt_pressed && trigger > triggerPressThreshold) || keyboardFire)
        {
            //fire weapon/tool if aiming, else switch inventory slots
            rt_pressed = true;
            if (aim.Equals(Vector2.zero))
            {
                //inventory.IncSlot();
            }
            else
            {
                //print("activating held item");
                if (inventory.Get())
                {
                    Fireable f = inventory.Get().GetComponent <Fireable>();
                    if (f)
                    {
                        f.Fire(aim, gameObject);
                    }
                }
                else
                {
                    Punch(aim);
                }
            }
        }
        if (rt_pressed && trigger < triggerReleaseThreshold)
        {
            rt_pressed = false;
        }

        //debug
        aimIndicator.transform.position = (Vector2)transform.position + aim_raw;
        float trigger_percentage = (trigger + 1) / 2;
        Color trigger_color      = (1 - trigger_percentage) * GetComponent <SpriteRenderer>().color;

        aimIndicator.GetComponent <SpriteRenderer>().color = new Color(trigger_color.r, trigger_color.g, trigger_color.b);

        float ltrigger = GetAxis("LTrigger");

        if (!lt_pressed && ltrigger > triggerPressThreshold)
        {
            //do not switch inventory slot
            lt_pressed = true;
            //inventory.DecSlot();
        }
        if (lt_pressed && ltrigger < triggerReleaseThreshold)
        {
            lt_pressed = false;
        }



        if (rb.velocity.sqrMagnitude > float.Epsilon * float.Epsilon)
        {
            timeSinceLastMoved = 0f;
            idle     = false;
            longIdle = false;
        }
        else
        {
            if (timeSinceLastMoved > timeUntilIdle)
            {
                idle = true;
            }

            if (timeSinceLastMoved > timeUntilLongIdle)
            {
                longIdle = true;
            }

            timeSinceLastMoved += Time.deltaTime;
        }

        if (idle && !idleLF)
        {
            GameManager.GetTextOverlayHandler(playerNum).AppearWords();
        }
        else if (!idle && idleLF)
        {
            GameManager.GetTextOverlayHandler(playerNum).DisappearWords();
        }

        if (longIdle && !longIdleLF)
        {
            GameManager.GetTextOverlayHandler(playerNum).AppearDefinitions();
        }
        else if (!longIdle && longIdleLF)
        {
            GameManager.GetTextOverlayHandler(playerNum).DisappearDefinitions();
        }

        idleLF     = idle;
        longIdleLF = longIdle;

        ////Interact with world
        if (Input.GetKeyDown(AButton) || (me.playerNum == keyboardControlledPlayer && (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.E))))
        {
            Interact();
        }
        else if (Input.GetKeyDown(BButton) || (me.playerNum == keyboardControlledPlayer && (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.R))))
        {
            Drop();
        }

        ////Adjust camera height out
        if (Input.GetKeyDown(YButton) || (me.playerNum == keyboardControlledPlayer && Input.GetKeyDown(KeyCode.LeftShift)))
        {
            camScript.ToggleZoom(zoomIn: false);
        }

        ////Adjust camera height in
        if (Input.GetKeyDown(XButton) || (me.playerNum == keyboardControlledPlayer && Input.GetKeyDown(KeyCode.RightShift)))
        {
            camScript.ToggleZoom(zoomIn: true);
        }

        ////Change which item is active
        if (Input.GetKeyDown(LeftBumper) || (me.playerNum == keyboardControlledPlayer && Input.GetKeyDown(KeyCode.LeftArrow)))
        {
            inventory.DecSlot();
        }
        else if (Input.GetKeyDown(RightBumper) || (me.playerNum == keyboardControlledPlayer && Input.GetKeyDown(KeyCode.RightArrow)))
        {
            inventory.IncSlot();
        }

        //make keyboardControlledPlayer adjustable by keyboard
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            keyboardControlledPlayer = 1;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            keyboardControlledPlayer = 2;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            keyboardControlledPlayer = 3;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            keyboardControlledPlayer = 4;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            keyboardControlledPlayer = 0;
        }
    }
Example #5
0
 public void Awake()
 {
     fireable = GetComponent <Fireable>();
 }
Example #6
0
 public virtual void SetUpFireableBehavior(Fireable fireable)
 {
     this.fireable = fireable;
 }
Example #7
0
 public void Setup(Player player)
 {
     // Copy the scriptable object
     fireable = Instantiate(fireable);
     fireable.Setup(player);
 }
Example #8
0
 public void Fire(Transform owner, Transform position, IDamager damager)
 {
     Fireable.Fire(owner, position, damager);
 }