コード例 #1
0
ファイル: C_CharacterHand.cs プロジェクト: Lysfith/GGJ2020
        public void Release()
        {
            if (!_isEnabled)
            {
                return;
            }

            if (_object == null)
            {
                return;
            }

            if (_triggerWorkbench.CurrentWorkbench != null && _triggerWorkbench.CurrentWorkbench.WorkbenchType != _object.ObjectType)
            {
                SoundManager.PlaySound(SoundList.Sound.error, gameObject);
                return;
            }

            _object.transform.SetParent(null);

            if (_triggerBot.CurrentBot != null)
            {
                _triggerBot.CurrentBot.AddPart(_object, this.gameObject);
            }
            else
            {
                _object.Release(this.gameObject);
            }

            _object = null;

            EnableHand();
        }
コード例 #2
0
ファイル: C_Bot.cs プロジェクト: Lysfith/GGJ2020
        public void AddPart(C_Object part, GameObject player)
        {
            if (part.ObjectType == ObjectType.WASTE ||
                _parts[part.ObjectType] != part.Version)
            {
                part.Release(player);
                return;
            }

            var robotArm  = part.GetComponent <C_RobotArm>();
            var robotPart = part.GetComponent <C_RobotPart>();

            if (robotArm == null && robotPart == null)
            {
                part.Release(player);
                return;
            }

            if ((robotArm != null && robotArm.Progress < 1) ||
                (robotPart != null && robotPart.Progress < robotPart.Hardness))
            {
                part.Release(player);
                return;
            }

            Transform partDestination = null;

            switch (part.ObjectType)
            {
            case ObjectType.CHEST:
                if (_chest)
                {
                    part.Release(player);
                    return;
                }
                _chest          = part;
                partDestination = _chestPosition;
                break;

            case ObjectType.HEAD:
                if (_head)
                {
                    part.Release(player);
                    return;
                }
                _head           = part;
                partDestination = _headPosition;
                break;

            case ObjectType.LEFT_ARM:
                if (_leftArm)
                {
                    part.Release(player);
                    return;
                }
                _leftArm        = part;
                partDestination = _leftArmPosition;
                break;

            case ObjectType.RIGHT_ARM:
                if (_rightArm)
                {
                    part.Release(player);
                    return;
                }
                _rightArm       = part;
                partDestination = _rightArmPosition;
                break;
            }
            SoundManager.PlaySound(SoundList.Sound.addpart);
            PopupManager.RemoveTipOnPlayer(this.gameObject);
            var botPartAnim = part.gameObject.AddComponent <C_BotPartAnimation>();

            partDestination = transform;
            botPartAnim.Init(partDestination, () =>
            {
                var go = GetGOFromTypeAndVersion(part.ObjectType, part.Version);
                go.SetActive(true);
                CheckBotCompleted();
            });
        }