예제 #1
0
        public bool CanMoveThrough(TouchDetectorType touchDetectorType)
        {
            if (controlMechanism.controlType == ControlType.ENEMY)
            {
                return(true);
            }

            if (TouchDetectors.ContainsKey(touchDetectorType))
            {
                TouchDetector t = TouchDetectors[touchDetectorType];
                if (t.IsTouching)
                {
                    foreach (GameObject obj in t.GeneralObjects)
                    {
                        if (obj.name.Contains("Enemy"))
                        {
                            if (controlMechanism.characterStateController.CurrentState.GetType() != typeof(PlayerRunningSlide))
                            {
                                AIControl ai = obj.GetComponent <AIControl>();
                                if (!ai.IsDead())
                                {
                                    return(false);
                                }
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
        public bool TriggerCollateralDamage()
        {
            if (StopDetecting)
            {
                return(false);
            }

            if (DetectionRoutine == null)
            {
                return(false);
            }

            if (characterData.TouchDetectors.ContainsKey(TouchDetectorType.CHARACTER_DETECTOR_BODY))
            {
                TouchDetector d = characterData.TouchDetectors[TouchDetectorType.CHARACTER_DETECTOR_BODY];
                if (d.IsTouching)
                {
                    if (d.TouchablesDictionary.ContainsKey(TouchableType.CHARACTER))
                    {
                        List <Touchable> touchables = d.TouchablesDictionary[TouchableType.CHARACTER];
                        foreach (Touchable touchable in touchables)
                        {
                            if (touchable.gameObject.name.Contains("Enemy"))
                            {
                                //Debug.Log("touch: " + touchable.gameObject.name);
                                AIControl aiControl = touchable.controlMechanism as AIControl;
                                if (!CollateralAIs.Contains(aiControl))
                                {
                                    CollateralAIs.Add(aiControl);
                                    aiControl.characterStateController.ForceDeath = true;
                                    aiControl.characterStateController.DeathCause = "Collateral";

                                    if (controlMechanism.IsFacingForward())
                                    {
                                        aiControl.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));
                                    }
                                    else
                                    {
                                        aiControl.transform.rotation = Quaternion.Euler(new Vector3(0f, 180f, 0f));
                                    }

                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }