Пример #1
0
    void tryFeedingSleigh()
    {
        GameObject           sleigh          = GameObject.FindGameObjectWithTag("Sleigh");
        ActionnableBehaviour sleighBehaviour = sleigh.GetComponent <ActionnableBehaviour>();

        if (sleighBehaviour != null && sleighBehaviour.playerInReach && takingObject && carriedBox != null)
        {
            ScoreBehaviour score = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreBehaviour>();
            BoxBehaviour   box   = carriedBox.GetComponent <BoxBehaviour>();
            if (box.toy.broken)
            {
                score.incrementScore(-100);
            }
            else
            {
                score.incrementScore(box.size * 100);
                AudioSource audio = sleigh.GetComponent <AudioSource>();
                if (audio != null)
                {
                    audio.Play();
                }
            }
            takingObject = false;
            Destroy(carriedBox);
            carriedBox = null;
        }
    }
Пример #2
0
 void tryInteractingWithBox()
 {
     GameObject[] boxes = GameObject.FindGameObjectsWithTag("box");
     foreach (GameObject box in boxes)
     {
         BoxBehaviour boxBehavior = box.GetComponent <BoxBehaviour>();
         if (boxBehavior != null && boxBehavior.playerInReach)
         {
             if (!boxBehavior.isClosed && !boxBehavior.isClosing && takingObject && carriedToy != null)
             {
                 Toy toy = carriedToy.GetComponent <ToyBehaviour>().toy;
                 if (toy.size == boxBehavior.size)
                 {
                     boxBehavior.toy = toy;
                     boxBehavior.packBox();
                     takingObject = false;
                     Destroy(carriedToy);
                     carriedToy = null;
                 }
             }
             else if (boxBehavior.isClosed && !takingObject)
             {
                 takingObject = true;
                 carriedBox   = box;
                 boxBehavior.takenByPlayer = true;
             }
         }
     }
 }
Пример #3
0
    public override void InitKillers(BoxBehaviour to)
    {
        var boardLength    = LevelManager.Instance.boardLength;
        var boxContainer   = LevelManager.Instance.boxContainer;
        var pieceTileCount = 0;

        for (int i = 0; i < stepPositions.Count; i++)
        {
            Vector2 pos = stepPositions[i] + to.address;

            if (pos.x < boardLength && pos.y < boardLength && pos.x >= 0 && pos.y >= 0)
            {
                BoxBehaviour newBox = boxContainer[(int)pos.x, (int)pos.y];
                pieceTileCount++;
                float delay = (newBox.address - to.address).magnitude / 10f;

                if (newBox.stats is ScoreValue)
                {
                    LevelManager.Instance.currentScore += ((ScoreValue)newBox.stats).score * 2;
                }

                var killerObj = Instantiate(to.frontPanel.gameObject, to.transform);
                killerObj.transform.position = to.frontPanel.transform.position;
                killerObj.AddComponent <Killer>().Init(to, newBox);
            }
        }
        LevelManager.Instance.pieceTileCount = pieceTileCount;
    }
 public override void Init(BoxBehaviour box)
 {
     // Debug.LogWarning("Enque");
     LevelManager.Instance.queue.Enqueue(new System.Action(() => {
         InitKillers(box);
         Contact(box, box);
     }));
 }
Пример #5
0
    public IMoveBehaviour GetMove(GameObject player)
    {
        BoxBehaviour newBox = new BoxBehaviour(player);

        newBox.prefabBox     = this.prefabBox;
        newBox.prefabBoxMove = this.prefabBoxMove;

        return(newBox);
    }
 public override bool Contact(BoxBehaviour from, BoxBehaviour to)
 {
     if (from.lastStats == to.stats)
     {
         to.animator.SetTrigger("Shake");
         return(false);
     }
     return(base.Contact(from, to));
 }
Пример #7
0
 public void Init(BoxBehaviour main, BoxBehaviour target)
 {
     this.transform.Translate(Vector3.back);
     this.main     = main;
     this.target   = target;
     this.speed    = (target.transform.position - this.transform.position).magnitude * 1.5f;
     this.animator = GetComponent <Animator>();
     this.sprite   = GetComponent <SpriteRenderer>();
 }
Пример #8
0
    void MakeCell(Cell cell, int x, int y)
    {
        GameObject   c = Instantiate(Cell, new Vector3(x, y, 0), Quaternion.identity) as GameObject;
        BoxBehaviour b = c.GetComponent <BoxBehaviour>();

        b.openColor = cell.getColor();
        b.kitty     = cell.isHealthy();
        b.mode      = playerData.CurrentPlayer.settings.playmode;
        pw.puzzleCount++;
    }
Пример #9
0
    public override bool Contact(BoxBehaviour from, BoxBehaviour to)
    {
        to.IdentifyBox();

        to.animator.SetTrigger("Rotate");
        if (from == to)
        {
            InitKillers(to);
            return(true);
        }
        return(false);
    }
Пример #10
0
 void groupClick(string s)
 {
     GameObject[] cells = GameObject.FindGameObjectsWithTag("Cell");
     foreach (GameObject cell in cells)
     {
         BoxBehaviour b = cell.GetComponent <BoxBehaviour>();
         if (b.highlightPlane.activeSelf)
         {
             b.highlightEvent(s);
             b.highlightPlane.SetActive(false);
         }
     }
 }
Пример #11
0
    void tryRope()
    {
        GameObject           rope          = GameObject.FindGameObjectWithTag("Rope");
        ActionnableBehaviour ropeBehaviour = rope.GetComponent <ActionnableBehaviour>();

        if (carriedBox == null && ropeBehaviour != null && ropeBehaviour.playerInReach)
        {
            AudioSource audio = rope.GetComponent <AudioSource>();
            if (audio != null)
            {
                audio.Play();
            }
            bool         smallBoxPresent = false, mediumBoxPresent = false, bigBoxPresent = false;
            GameObject[] boxes = GameObject.FindGameObjectsWithTag("box");
            foreach (GameObject box in boxes)
            {
                BoxBehaviour boxBehaviour = box.GetComponent <BoxBehaviour>();
                if (boxBehaviour != null)
                {
                    switch (boxBehaviour.size)
                    {
                    case 1:
                        smallBoxPresent = true;
                        break;

                    case 2:
                        mediumBoxPresent = true;
                        break;

                    case 3:
                        bigBoxPresent = true;
                        break;
                    }
                }
            }
            if (!smallBoxPresent)
            {
                GameObject.Instantiate(Resources.Load("10_PREFABS/SmallBox"), BoxBehaviour.smallBoxPosition, new Quaternion());
            }
            if (!mediumBoxPresent)
            {
                GameObject.Instantiate(Resources.Load("10_PREFABS/MediumBox"), BoxBehaviour.mediumBoxPosition, new Quaternion());
            }
            if (!bigBoxPresent)
            {
                GameObject.Instantiate(Resources.Load("10_PREFABS/BigBox"), BoxBehaviour.bigBoxPosition, new Quaternion());
            }
        }
    }
Пример #12
0
    public override bool Contact(BoxBehaviour from, BoxBehaviour to)
    {
        if (from == to)
        {
            to.animator.SetTrigger("Shake");
            to.source.PlayOneShot(blockSound);

            return(false);
        }
        if (score > 0)
        {
            to.source.PlayOneShot(triggerSound);
            to.particle.Play();
            UiManager.Instance.CreateCoin(new Vector3(to.transform.position.x, to.transform.position.y, to.transform.position.z - 5));
        }
        to.IdentifyBox();
        to.animator.SetTrigger("Rotate");
        return(true);
    }
Пример #13
0
    PuzzleLine createLine(List <GameObject> clues, List <GameObject> cells)
    {
        List <bool> open       = new List <bool>();
        List <bool> kitties    = new List <bool>();
        List <int>  clueValues = new List <int>();

        foreach (GameObject cell in cells)
        {
            BoxBehaviour b = cell.GetComponent <BoxBehaviour>();
            open.Add(b.isOpen);
            kitties.Add(b.kitty);
        }
        foreach (GameObject clue in clues)
        {
            ClueBehavior c = clue.GetComponent <ClueBehavior>();
            clueValues.Add(c.clueValue);
        }

        return(new PuzzleLine(open, kitties, clueValues, clues));
    }
Пример #14
0
    public override bool Contact(BoxBehaviour from, BoxBehaviour to)
    {
        if (from.lastStats is ChainBreakerValue)
        {
            to.animator.SetTrigger("Rotate");
            to.IdentifyBox();
        }
        else
        {
            to.animator.SetTrigger("Shake");
            to.source.PlayOneShot(blockSound);
            to.FinishAnimation();
        }

        if (from == to)
        {
            return(false);
        }
        return(true);
    }
    public static void CheckBox_Player(PlayerBehaviour player, BoxBehaviour box)
    {
        CubeBehaviour a = player.cube;
        CubeBehaviour b = box.cube;

        if ((a.min.x <= b.max.x && a.max.x >= b.min.x) &&
            (a.min.y <= b.max.y && a.max.y >= b.min.y) &&
            (a.min.z <= b.max.z && a.max.z >= b.min.z))
        {
            if (box.body.bodyType == BodyType.DYNAMIC)
            {
                if (Input.GetAxisRaw("Vertical") > 0.0f && !(a.min.y >= b.max.y - 1.0f))
                {
                    box.body.velocity = player.playerCam.transform.forward * player.speed * Time.deltaTime;
                }
            }
            else
            {
                player.blocked = true;
            }
        }
    }
Пример #16
0
    void Update()
    {
        int x = 0, y = 0;

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            y = 1;
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            y = -1;
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            x = 1;
        }
        else if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            x = -1;
        }

        Vector2      movement = new Vector2(x, y);
        Collider2D   collider = Physics2D.OverlapBox(movement + (Vector2)transform.position, Vector2.one * 0.01f, 0.0f);
        BoxBehaviour box      = collider?.GetComponent <BoxBehaviour>();

        if (!collider || box || collider?.gameObject.tag == "StockPlace")
        {
            bool canMove = true;
            if (box)
            {
                canMove = box.Move(movement);
            }

            if (canMove)
            {
                transform.position = movement + (Vector2)transform.position;
            }
        }
    }
 public void QueFunc(BoxBehaviour box)
 {
     InitKillers(box);
     Contact(box, box);
 }
 public override bool Contact(BoxBehaviour from, BoxBehaviour to)
 {
     return(base.Contact(from, to));
 }
Пример #19
0
 public virtual void Init(BoxBehaviour box)
 {
 }
Пример #20
0
 public abstract bool Contact(BoxBehaviour from, BoxBehaviour to);
Пример #21
0
 public bool Trigger(BoxBehaviour killer)
 {
     // Debug.Log("Trugger");
     return(stats.Contact(killer, this));
 }
Пример #22
0
    void Update()
    {
        // Movement
        var moveDir = new Vector3();

        if (Input.GetKey(KeyCode.W))
        {
            moveDir += Vector3.forward;
        }
        if (Input.GetKey(KeyCode.A))
        {
            moveDir += Vector3.left;
        }
        if (Input.GetKey(KeyCode.S))
        {
            moveDir += Vector3.back;
        }
        if (Input.GetKey(KeyCode.D))
        {
            moveDir += Vector3.right;
        }

        // if moving to any direction
        movement.Move(moveDir);

        // Jump
        if (Input.GetKeyDown(KeyCode.Space) && grounded)
        {
            movement.Jump();
            grounded = false;
        }

        // Rotation
        if (attacking.GetHasWeapon())
        {
            rotation.RotateToMousePosition();
        }
        else
        {
            rotation.RotateToDirection(moveDir);
        }

        // Attacking
        if (Input.GetKeyDown(KeyCode.Mouse0) && currentHeldBox == null)
        {
            attacking.Attack();
        }

        // Box holding
        if (Input.GetKeyDown(KeyCode.E))
        {
            var cols = boxCheck.BoxCheck(boxMask);
            foreach (Collider c in cols)
            {
                currentHeldBox = c.transform.root.GetComponentInChildren <BoxBehaviour>();
                if (currentHeldBox != null)
                {
                    currentHeldBox.Hold(transform);
                    break;
                }
            }
        }

        // Box throwing
        if (Input.GetKeyDown(KeyCode.Mouse0) && currentHeldBox != null)
        {
            currentHeldBox.Throw(transform.forward);
            currentHeldBox = null;
        }

        // DEBUG MODESWITCH
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            attacking.hasWeapon = false;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            attacking.hasWeapon = true;
        }
    }