Пример #1
0
 public void SetStateChildren(PartState nextState)
 {
     if (childPart != null)
     {
         childPart.SetStateRecursive(nextState);
     }
 }
Пример #2
0
    public void OnChange(int prevIdx)
    {
        Color color = Color.white;

        switch (machine.GetActiveState())
        {
        case 0: color = Color.white; break;

        case 1: color = thisBody.mainColor; break;

        case 2: color = selectedColor; break;

        case 3: color = Color.red; break;

        case 4: color = Color.magenta; break;

        case 5: color = Color.cyan; break;

        case 6: color = Color.yellow; break;

        case 7: color = Color.white; break;
        }
        debugState = (PartState)machine.GetActiveState();
        //PartState lastState = (PartState)prevIdx;
        SetColor(color);
    }
Пример #3
0
 public void SetStateRecursive(PartState nextState)
 {
     machine.SetState(nextState);
     if (childPart != null)
     {
         childPart.SetStateRecursive(nextState);
     }
 }
Пример #4
0
 public void Die()
 {
     partState = PartState.Dead;
     if (onStateChange != null)
     {
         onStateChange(partState);
     }
 }
Пример #5
0
 public void Pick()
 {
     partState = PartState.Picked;
     if (onStateChange != null)
     {
         onStateChange(partState);
     }
 }
Пример #6
0
 void OnEnable()
 {
     fixedJoint.enabled       = false;
     fixedJoint.connectedBody = null;
     partState = PartState.Wait;
     if (onStateChange != null)
     {
         onStateChange(partState);
     }
     rigidbody.gravityScale = 1f;
 }
Пример #7
0
 public void Stick(Rigidbody2D body)
 {
     partState = PartState.Stuck;
     if (onStateChange != null)
     {
         onStateChange(partState);
     }
     fixedJoint.enabled       = true;
     fixedJoint.connectedBody = body;
     GameManager.instance.musicManager.PlayAttachSound();
     GameManager.instance.musicManager.PlayShout();
 }
Пример #8
0
        public void OnConstruct()
        {
            // DebugUtils.Log("SmashedView.OnConstruct()");
            int partsCount = parts.Length;

            initialPartStates = new PartState[partsCount];

            for (int i = 0; i < partsCount; ++i)
            {
                Transform part = parts[i];
                initialPartStates[i] = new PartState {
                    LocalPosition = part.localPosition,
                    LocalRotation = part.localRotation
                };
            }
        }
Пример #9
0
        void IPoolable.OnReturn()
        {
            for (int i = 0; i < parts.Length; ++i)
            {
                Transform part             = parts[i];
                PartState initialPartState = initialPartStates[i];
                part.localPosition = initialPartState.LocalPosition;
                part.localRotation = initialPartState.LocalRotation;
                var partBody = part.GetComponent <Rigidbody>();

                if (partBody == null)
                {
                    continue;
                }

                partBody.Sleep();
            }
        }
Пример #10
0
    private IEnumerator DisassemblyPart()
    {
        Inventory.instance.ItemsList.Add(this);

        ShowDefaultPart(false);
        Cursor.visible = false;
        ControlType.instance.inputAllowed = false;

        for (int i = 0; i < 20; i++)
        {
            transform.position += direction / 60;
            yield return(new WaitForSeconds(0.01f));
        }

        state = PartState.dismounted;
        transform.localPosition = startPos;
        meshRendered.enabled    = false;

        collider.enabled = false;

        Cursor.visible = true;
        ControlType.instance.inputAllowed = true;
    }
Пример #11
0
    private IEnumerator AssemblyPart()
    {
        ShowDefaultPart(false);
        Cursor.visible = false;
        ControlType.instance.inputAllowed = false;

        transform.position += direction / 60 * 20;

        for (int i = 0; i < 20; i++)
        {
            transform.position -= direction / 60;
            yield return(new WaitForSeconds(0.01f));
        }

        state = PartState.installed;
        transform.localPosition = startPos;


        Cursor.visible = true;
        ControlType.instance.inputAllowed = true;

        Car.instance.DisplayAllDissamblyParts();
    }
Пример #12
0
    public void UpdateSprite()
    {
        headState      = _bodyPartStates[BodyPart.Head];
        leftHandState  = _bodyPartStates[BodyPart.LeftHand];
        rightHandState = _bodyPartStates[BodyPart.RightHand];
        leftLegState   = _bodyPartStates[BodyPart.LeftLeg];
        rightLegState  = _bodyPartStates[BodyPart.RightLeg];
        batteryState   = _bodyPartStates[BodyPart.Battery];

        foreach (var partAndState in _bodyPartStates)
        {
            BodyPart  part  = partAndState.Key;
            PartState state = partAndState.Value;

            if (part != BodyPart.Battery)
            {
                if (state == PartState.Broken)
                {
                    _bodyPartGameObjects[part].SetActive(false);
                }
                else if (state == PartState.Normal)
                {
                    _bodyPartGameObjects[part].SetActive(true);
                }
            }
        }

        if (_bodyPartStates[BodyPart.Battery] == PartState.Broken)
        {
            bodySpriteRenderer.sprite = bodyUnpoweredSprite;
        }
        else if (_bodyPartStates[BodyPart.Battery] == PartState.Normal)
        {
            bodySpriteRenderer.sprite = bodyPoweredSprite;
        }
    }
Пример #13
0
 /// <summary>
 /// コンストラクタ(ステータス指定)
 /// </summary>
 public PartDataArmor(Part part, PartState state)
     : base(part)
 {
     this.State  = state;
     this.Master = null;
 }