Пример #1
0
        public void Throw()
        {
            if (!_isEnabled)
            {
                return;
            }

            if (_object == null)
            {
                return;
            }

            if (_object.gameObject.layer == LayerMask.NameToLayer("Waste"))
            {
                _object.Throw(transform.forward, this.gameObject);
                _object = null;
                EnableHand();
                return;
            }

            var hits = Physics.RaycastAll(_character.transform.position + Vector3.up, transform.forward, _raycastDistance, LayerMask.GetMask("Wall", "WallObjectWaste"));

            if (!hits.Any())
            {
                var box = _object.GetComponent <C_Box>();
                if (box == null)
                {
                    _object.Throw(transform.forward, this.gameObject);
                }
                else
                {
                    box.Open(this.gameObject);
                }

                _object = null;

                EnableHand();
            }
        }
Пример #2
0
        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();
            });
        }