예제 #1
0
        public ActorBehaviour SpawnActor(ActorType actorType, Vector2Int position, bool isBoss = false)
        {
            ActorBehaviour instantiatedActor = _actorBehaviourFactory.Create();

            instantiatedActor.name = actorType.ToString();
            ActorData actorData = instantiatedActor.ActorData;

            actorData.ActorType = actorType;
            actorData.IsBoss    = isBoss;

            ActorDefinition actorDefinition = _gameConfig.ActorConfig.GetDefinition(actorType);

            instantiatedActor.GetComponent <SpriteRenderer>().sprite = actorDefinition.Sprite;
            actorData.WeaponWeld      = _rng.Choice(actorDefinition.WeaponPool);
            actorData.SwordsFromSkill = actorDefinition.SwordsFromSkill;
            actorData.VisionRayLength = actorDefinition.VisionRayLength;
            actorData.EnergyGain      = actorDefinition.EnergyGain;
            actorData.Team            = actorDefinition.Team;
            actorData.MaxHealth       = actorDefinition.MaxHealth;
            actorData.Health          = actorDefinition.MaxHealth;
            actorData.Accuracy        = actorDefinition.Accuracy;
            actorData.XpGiven         = actorDefinition.XpGiven;
            actorData.Level           = actorDefinition.InitialLevel;
            actorData.Traits          = actorDefinition.InitialTraits.ToArray().ToList();
            actorData.AiTraits        = actorDefinition.AiTraits.ToArray().ToList();

            Vector2Int freePosition = GetPositionToPlaceActor(position);

            actorData.LogicalPosition = freePosition;
            instantiatedActor.RefreshWorldPosition();
            _gameContext.Actors.Add(instantiatedActor);
            instantiatedActor.gameObject.SetActive(true);
            return(instantiatedActor);
        }