Пример #1
0
        public static AIActor SetupAIActorDummy(string name, IntVector2 colliderOffset, IntVector2 colliderDimensions)
        {
            GameObject obj = new GameObject(name);

            obj.SetActive(false);
            FakePrefab.MarkAsFakePrefab(obj);
            UnityEngine.Object.DontDestroyOnLoad(obj);
            tk2dSprite           sprite        = obj.AddComponent <tk2dSprite>();
            SpeculativeRigidbody body          = sprite.SetUpSpeculativeRigidbody(colliderOffset, colliderDimensions);
            PixelCollider        pixelCollider = new PixelCollider();

            pixelCollider.ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual;
            pixelCollider.CollisionLayer         = CollisionLayer.EnemyCollider;
            pixelCollider.ManualWidth            = colliderDimensions.x;
            pixelCollider.ManualHeight           = colliderDimensions.y;
            pixelCollider.ManualOffsetX          = colliderOffset.x;
            pixelCollider.ManualOffsetY          = colliderOffset.y;
            body.PixelColliders.Add(pixelCollider);
            body.PrimaryPixelCollider.CollisionLayer = CollisionLayer.EnemyCollider;
            AIActor     aiactor = obj.AddComponent <AIActor>();
            HealthHaver hh      = obj.AddComponent <HealthHaver>();

            hh.SetHealthMaximum(10f);
            hh.ForceSetCurrentHealth(10f);
            BehaviorSpeculator spec = obj.AddComponent <BehaviorSpeculator>();

            ((ISerializedObject)spec).SerializedObjectReferences = new List <UnityEngine.Object>(0);
            ((ISerializedObject)spec).SerializedStateKeys        = new List <string> {
                "OverrideBehaviors", "OtherBehaviors", "TargetBehaviors", "AttackBehaviors", "MovementBehaviors"
            };
            ((ISerializedObject)spec).SerializedStateValues = new List <string> {
                "", "", "", "", ""
            };
            return(aiactor);
        }
        private void ModifyHP(HealthHaver hp)
        {
            float startMax = hp.GetMaxHealth();

            hp.SetHealthMaximum(startMax * 0.25f);
            hp.ForceSetCurrentHealth(startMax * 0.25f);
        }
        public void SpawnNewTurtle()
        {
            string              guid           = PickupObjectDatabase.GetById(645).GetComponent <MulticompanionItem>().CompanionGuid;
            AIActor             orLoadByGuid   = EnemyDatabase.GetOrLoadByGuid(guid);
            Vector3             vector         = player.transform.position;
            GameObject          gameObject     = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity);
            CompanionController orAddComponent = gameObject.GetOrAddComponent <CompanionController>();

            this.activeTurtles.Add(gameObject);
            orAddComponent.Initialize(player);
            if (orAddComponent.specRigidbody)
            {
                PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(orAddComponent.specRigidbody, null, false);
            }
            HealthHaver helf = gameObject.GetComponent <HealthHaver>();

            if (helf != null)
            {
                float helfNew = helf.GetMaxHealth() * 3f;
                helf.SetHealthMaximum(helfNew);
                helf.ForceSetCurrentHealth(helfNew);
            }
        }