Пример #1
0
    void Update()
    {
        Vector2 targetVelocity = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

        Move(targetVelocity);
        SetSortingOrder();

        if (Input.GetKeyDown(KeyCode.M))
        {
            if (!al.gameObject.activeSelf)
            {
                al.Menu();
                al.InTrigger(true);
                al.gameObject.SetActive(true);
            }
            else
            {
                al.InTrigger(false);
                al.gameObject.SetActive(false);
            }
        }
    }
Пример #2
0
    public void OnClick()
    {
        if (this.count == 0)
        {
            return;
        }
        if (controller.isHoldingPart)
        {
            return;
        }

        if (slot == Slot.body)
        {
            RobotType type;
            if (Enum.TryParse <RobotType>(itemName.text, out type))
            {
                inventory.bodies[type]--;
                GameObject body = Instantiate(list.botBodyPrefab);
                body.GetComponent <BotBody>().robotType     = type;
                body.GetComponent <BotBody>().isBroken      = false;
                body.GetComponent <SpriteRenderer>().sprite = body.GetComponent <BotBody>().GetSprite();
                list.BuildBodyList(inventory.bodies);
                controller.TakePart(body);
                list.InTrigger(false);
            }
        }
        else if (slot == Slot.head)
        {
            HeadType type;
            if (Enum.TryParse <HeadType>(itemName.text, out type))
            {
                inventory.heads[type]--;
                GameObject head = Instantiate(list.botHeadPrefab);
                head.GetComponent <BotHead>().headType      = type;
                head.GetComponent <BotHead>().isBroken      = false;
                head.GetComponent <SpriteRenderer>().sprite = head.GetComponent <BotHead>().GetSprite();
                list.BuildHeadList(inventory.heads);
                controller.TakePart(head);
                list.InTrigger(false);
            }
        }
        else if (slot == Slot.leftArm || slot == Slot.rightArm)
        {
            ArmType type;
            if (Enum.TryParse <ArmType>(itemName.text, out type))
            {
                inventory.arms[type]--;
                GameObject arm = Instantiate(list.armPrefab);
                arm.GetComponent <BotArm>().armType        = type;
                arm.GetComponent <BotArm>().isBroken       = false;
                arm.GetComponent <SpriteRenderer>().sprite = arm.GetComponent <BotArm>().GetSprite();
                list.BuildArmsList(inventory.arms);
                controller.TakePart(arm);
                list.InTrigger(false);
            }
        }
        else if (slot == Slot.leftLeg || slot == Slot.rightLeg)
        {
            LegType type;
            if (Enum.TryParse <LegType>(itemName.text, out type))
            {
                inventory.legs[type]--;
                GameObject leg = Instantiate(list.legPrefab);
                leg.GetComponent <BotLeg>().legType        = type;
                leg.GetComponent <BotLeg>().isBroken       = false;
                leg.GetComponent <SpriteRenderer>().sprite = leg.GetComponent <BotLeg>().GetSprite();
                list.BuildLegsList(inventory.legs);
                controller.TakePart(leg);
                list.InTrigger(false);
            }
        }
    }
Пример #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     inTriggerArea = true;
     tag.SetActive(true);
     assetList.InTrigger(true);
 }