Beispiel #1
0
        public void AttachAbilityToPart(LimbType type, Limb newLimb)
        {
            Blob      part   = GetBodyPart(type);
            LimbPunch action = null;

            if (newLimb.type == Limb.LimbComponentType.Head)
            {
                if (newLimb.head == Limb.HeadSubType.Bite)
                {
                    action = new BiteHead(this, type);
                }
                else if (newLimb.head == Limb.HeadSubType.Bomb)
                {
                    action = new BombHead(this, type);
                }
                else if (newLimb.head == Limb.HeadSubType.Laser)
                {
                    action = new LaserHead(this, type);
                }
                else if (newLimb.head == Limb.HeadSubType.Human)
                {
                    action = new HumanHead(this, type);
                }
            }
            else if (newLimb.type == Limb.LimbComponentType.Arm)
            {
                if (newLimb.arm == Limb.ArmSubType.Hammer)
                {
                    action = new HammerArm(this, type);
                }
                else if (newLimb.arm == Limb.ArmSubType.Hook)
                {
                    action = new HookArm(this, type);
                }
                else if (newLimb.arm == Limb.ArmSubType.Long)
                {
                    action = new LongArm(this, type);
                }
                else if (newLimb.arm == Limb.ArmSubType.Human)
                {
                    action = new HumanArm(this, type);
                }
            }
            else if (newLimb.type == Limb.LimbComponentType.Leg)
            {
                if (newLimb.leg == Limb.LegSubType.Gun)
                {
                    action = new GunLeg(this, type);
                }
                else if (newLimb.leg == Limb.LegSubType.Rocket)
                {
                    action = new RocketLeg(this, type);
                }
                else if (newLimb.leg == Limb.LegSubType.Human)
                {
                    action = new HumanArm(this, type);
                }
            }

            part.AddComponent(action);
        }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (!ui)
        {
            ui = GameObject.Find("CreatorUI").GetComponent <CreatorHud>();
            ui.updateMoneyText(money);
            setObjRenderer();
        }
        float inputXAmount = Input.GetAxis("L_XAxis_" + contToUse);
        float inputYAmount = Input.GetAxis("L_YAxis_" + contToUse);

        float rTriggerAmount = Input.GetAxis("TriggersR_" + contToUse);

        if (Input.GetButtonDown("A_" + contToUse))
        {
            spawnGameObject();
        }

        if (Input.GetButtonDown("RB_" + contToUse))
        {
            if (currObj < availableObjs.Count - 1)
            {
                currObj++;
            }
            else
            {
                currObj = 0;
            }
            setObjRenderer();
        }
        if (Input.GetButtonDown("LB_" + contToUse))
        {
            if (currObj > 0)
            {
                currObj--;
            }
            else
            {
                currObj = availableObjs.Count - 1;
            }
            setObjRenderer();
        }

        // Calculate how much the velocity should change based on xAccel
        Vector3 direction = new Vector3(inputXAmount, -inputYAmount, 0.0f) * (1f - (2 * rTriggerAmount));

        transform.Translate(moveSpeed * direction * Time.deltaTime);

        GetComponent <CircleCollider2D> ().attachedRigidbody.WakeUp();

        Trap thisObj = availableObjs [currObj];
        // Reset the snapped object if out of range of any cubes
        LayerMask platforms = LayerMask.GetMask("Platforms");

        if (snappedEdge == null || !GetComponent <CircleCollider2D> ().IsTouchingLayers(platforms) ||
            Input.GetButton("Y_" + contToUse) || !thisObj.canPlaceOnWalls)
        {
            // Reset the object snapped to
            snappedEdge = null;
            currObjRenderer.localPosition = new Vector3(0, 0, 0);
            currObjRenderer.eulerAngles   = new Vector3(0, 0, 0);
        }
        else
        {
            /* Update currObjectRenderer's position/rotation on the snapped edge
             * manually, as this may not be called every frame. This prevents the
             * object from being shaky when moving. */
            if (snappedEdge != null)
            {
                OnTriggerStay2D(snappedEdge.gameObject.GetComponent <BoxCollider2D> ());
            }
        }

        //Check if you can place this object right now
        canPlace = (thisObj.canPlaceInAir || snappedEdge != null);

        //Check if this object is being placed on another
        if (currObjRenderer.GetComponent <CreatorObjRenderer>().colliding)
        {
            canPlace = false;
        }
        //Check if a laser hits something
        if (thisObj.name.Equals("Laser") && !LaserHead.checkLaser(currObjRenderer.transform.position,
                                                                  currObjRenderer.transform.rotation))
        {
            canPlace = false;
        }

        Color color;

        if (canPlace)
        {
            color = new Color(1f, 1f, 1f, 0.7f);
        }
        else
        {
            color = new Color(1f, 0f, 0f, 0.3f);
        }
        currObjRenderer.GetComponent <SpriteRenderer> ().color = color;
    }