コード例 #1
0
 private void Start()
 {
     movement   = GetComponent <MovementBehavior>();
     attack     = GetComponent <AttackBehavior>();
     player     = GetComponent <WizardBehavior>();
     playerAnim = GetComponentInChildren <AnimationBehavior>();
 }
コード例 #2
0
ファイル: Companion.cs プロジェクト: IndiegameGarden/Quest
        public Companion()
            : base("pixie")
        {
            IsCollisionFree = false;

            SetColors(4f, new Color(38, 30, 240), new Color(150, 150, 255));

            Pushing.Force = RandomMath.RandomBetween(1f, 1.5f);

            SubsumptionBehavior sub = new SubsumptionBehavior();

            Add(sub);

            Combat = new CombatBehavior(typeof(RedGuard));
            sub.Add(Combat);

            ChasingHero                = new ChaseBehavior(Level.Current.pixie);
            ChasingHero.ChaseRange     = 370f;
            ChasingHero.SatisfiedRange = 6f;
            ChasingHero.MoveDeltaTime  = RandomMath.RandomBetween(1.2f, 1.5f);
            sub.Add(ChasingHero);

            ChasingRedGuard               = new ChaseBehavior(typeof(RedGuard));
            ChasingRedGuard.ChaseRange    = 20f;
            ChasingRedGuard.MoveDeltaTime = RandomMath.RandomBetween(1.1f, 1.5f);
            sub.Add(ChasingRedGuard);

            Attacking = new AttackBehavior(Level.Current.pixie);
            Attacking.AttackDuration = RandomMath.RandomBetween(1.5f, 2.8f);
            sub.Add(Attacking);

            Wandering = new RandomWanderBehavior(2.7f, 11.3f);
            Wandering.MoveDeltaTime = RandomMath.RandomBetween(0.09f, 0.25f);
            sub.Add(Wandering);
        }
コード例 #3
0
ファイル: Enemy.cs プロジェクト: coolchoon/portfolio
        IEnumerator Start()
        {
            Sequence root = new Sequence();

            Selector selector = new Selector();

            Sequence attackSequence = new Sequence();

            Node isAlivedBehavior = new IsAlivedBehavior(this);
            Node detectBehavior   = new DetectBehavior(this);
            Node attackBehavior   = new AttackBehavior(this);
            Node patrolBehavior   = new PatrolBehavior(this);

            root.AddChild(selector);

            root.AddChild(isAlivedBehavior);

            selector.AddChild(attackSequence);

            attackSequence.AddChild(detectBehavior);
            attackSequence.AddChild(attackBehavior);

            selector.AddChild(patrolBehavior);

            while (root.Invoke())
            {
                yield return(null);
            }
        }
コード例 #4
0
 public virtual void Tick(RealmTime time)
 {
     if (this is Projectile)
     {
         return;
     }
     if (interactive && Owner != null)
     {
         if (!HasConditionEffect(ConditionEffects.Stasis))
         {
             MovementBehavior.Tick(this, time);
             AttackBehavior.Tick(this, time);
             ReproduceBehavior.Tick(this, time);
         }
         foreach (var i in CondBehaviors)
         {
             if ((i.Condition & BehaviorCondition.Other) != 0 &&
                 i.ConditionMeet(this))
             {
                 i.Behave(BehaviorCondition.Other, this, time, null);
             }
         }
         posHistory[posIdx++] = new Position {
             X = X, Y = Y
         };
         ProcessConditionEffects(time);
     }
 }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        attackBehavior       = GetComponent <AttackBehavior>();
        PlayerCharController = GetComponent <ClickyMove>();
        healthBar            = config.manager.playerHealthBar;
        if (handBone)
        {
            // TODO: make switch at runtime.
            foreach (var w in weapons)
            {
                var gb = GameObject.Instantiate(w, handBone);
                gb.SetActive(weapons.IndexOf(w) == (int)weaponSelected);

                // 1 is punch, 0 is swing sword, more action types will be added here.
                AttackType = (int)weaponSelected;

                if (gb.activeInHierarchy)
                {
                    attackBehavior.weaponScript = gb.GetComponent <WeaponPlayable>();
                    attackBehavior.weaponScript.PlayerCharController = this.PlayerCharController;
                }
            }
        }

        //set health stuff
        currentHealth = maxHealth;
        //healthBarCanvas = GameObject.Find("AwesomeUI").GetComponent<Canvas>();

        //canvasRect = healthBarCanvas.GetComponent<RectTransform>();
        //cam = Camera.main;
        //healthBar.transform.SetParent(healthBarCanvas.transform);
    }
コード例 #6
0
    private void Die()
    {
        if (StateCurrent == State.Figth)
        {
            AttackBehavior.Untarget();
        }

        StateCurrent = State.Die;
    }
コード例 #7
0
        public void InitializeBehavior()
        {
            var arrow = transform.GetChild(1).gameObject;

            if (Type == CreatureType.Melee)
            {
                behavior = new AttackMelee(Attributes.Damage, creatureHelper.AttackMelee, arrow);
                return;
            }
            behavior = new AttackRange(Attributes.Damage, Attributes.Range, creatureHelper.AttackRange, arrow);
        }
コード例 #8
0
    private void MoveToEnemy(Vector3 position, HealthBehaviour health)
    {
        if (StateCurrent == State.Figth)
        {
            AttackBehavior.Untarget();
        }

        MoveToPosition(position, DistanceToEnemy);
        CreateEffect(position, Vector3.up, EffectFigthRef);

        StartCoroutine(WaitForEndMoveToEnemy(health));

        StateCurrent = State.MoveToEnemy;
    }
コード例 #9
0
    private void MoveToPoint(Vector3 position, Vector3 normal)
    {
        if (StateCurrent == State.Figth)
        {
            AttackBehavior.Untarget();
        }


        MoveToPosition(position);
        CreateEffect(position, normal, EffectMoveRef);

        StartCoroutine(WaitForEndMoveToPoint());

        StateCurrent = State.MoveToPoint;
    }
コード例 #10
0
    private void ConstructCharacter(GameObject characterPrefab, Vector3 position, BuildingCategory favoriteCategory,
                                    int hp, int armorCategory, float moveVelocity, TargetType type, float attackCD, int attackValue, float attackScope,
                                    int damageScope, float middleSpeed, int attackCategory, TargetType targetType, float pushFactor, float pushAttenuateFactor)
    {
        GameObject army = GameObject.Instantiate(characterPrefab) as GameObject;

        army.transform.position = position;
        army.transform.parent   = this.m_ParentNode;

        CharacterAI ai = army.GetComponent <CharacterAI>();

        ai.BattleMapData       = BattleMapData.Instance;
        ai.BattleSceneHelper   = this.m_SceneHelper;
        ai.FavoriteCategory    = favoriteCategory;
        ai.PushFactor          = pushFactor;
        ai.PushAttenuateFactor = pushAttenuateFactor;

        ai.SetIdle(true);

        CharacterHPBehavior hpBehavior = army.GetComponent <CharacterHPBehavior>();

        hpBehavior.TotalHP       = hp;
        hpBehavior.ArmorCategory = armorCategory;
        if (hpBehavior is KodoHPBehavior)
        {
            KodoHPBehavior kodoHP = hpBehavior as KodoHPBehavior;
            kodoHP.Factory = this;
        }

        CharacterPropertyBehavior property = army.GetComponent <CharacterPropertyBehavior>();

        property.CharacterType = CharacterType.Invader;
        property.MoveVelocity  = moveVelocity;
        property.Type          = type;

        AttackBehavior attackBehavior = army.GetComponent <AttackBehavior>();

        attackBehavior.BulletParent   = this.m_BulletParent;
        attackBehavior.AttackCD       = Mathf.FloorToInt(attackCD * ClientConfigConstants.Instance.TicksPerSecond);
        attackBehavior.AttackValue    = attackValue;
        attackBehavior.AttackScope    = attackScope;
        attackBehavior.DamageScope    = damageScope;
        attackBehavior.BulletFlySpeed = middleSpeed;
        attackBehavior.AttackCategory = attackCategory;
        attackBehavior.TargetType     = targetType;
        BattleSceneHelper.Instance.ConstructActor
            (army, PositionConvertor.GetActorTileIndexFromWorldPosition(army.transform.position));
    }
コード例 #11
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            attackBehavior = GetComponent <SingleShot>();
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            attackBehavior = GetComponent <SpreadShot>();
        }

        if (Input.GetMouseButtonDown(0))
        {
            HandleAttack();
        }
    }
コード例 #12
0
        public Knight()
            : base("pixie")
        {
            IsCollisionFree = false;

            SetColors(4f, new Color(28, 20, 230), new Color(76, 76, 255));
            Health = 13f;

            Pushing.Force = RandomMath.RandomBetween(1f, 1.5f);

            ComplexBehavior        = new SubsumptionBehavior();
            ComplexBehavior.Active = false; // initially, knight stays near square table.
            Add(ComplexBehavior);

            Combat = new CombatBehavior(typeof(RedGuard));
            ComplexBehavior.Add(Combat);

            ChasingHero                = new ChaseBehavior(Level.Current.hero);
            ChasingHero.ChaseRange     = 20f;
            ChasingHero.SatisfiedRange = 8f;
            ChasingHero.MoveSpeed      = RandomMath.RandomBetween(1.54f, 1.87f);
            ComplexBehavior.Add(ChasingHero);

            var tb = new PathFindToTargetBehavior()
            {
                ChaseTarget    = Level.Current.hero,
                ChaseRange     = 970f,
                SatisfiedRange = ChasingHero.ChaseRange - 2f
            };

            ComplexBehavior.Add(tb);

            ChasingRedGuard            = new ChaseBehavior(typeof(RedGuard), true);
            ChasingRedGuard.ChaseRange = 20f;
            ChasingRedGuard.MoveSpeed  = RandomMath.RandomBetween(1.1f, 1.5f);
            ComplexBehavior.Add(ChasingRedGuard);

            Attacking = new AttackBehavior(Level.Current.hero);
            Attacking.AttackDuration = RandomMath.RandomBetween(1.9f, 2.95f);
            ComplexBehavior.Add(Attacking);

            Wandering           = new RandomWanderBehavior(15.7f, 23.3f);
            Wandering.MoveSpeed = RandomMath.RandomBetween(0.001f, 0.02f);
            ComplexBehavior.Add(Wandering);
        }
コード例 #13
0
ファイル: AIFactory.cs プロジェクト: linxiubao/UniShader
    // 根据战士类型和阵营来创建AI,根据阵营和战士类型来创建目标选择策略
    public AIBase createAI(Toy pToy, HERO_TYPE eHeroType, CAMP_TYPE eCampType)
    {
        AIBase pAI = null;
        switch (eHeroType)
        {
            case HERO_TYPE.AI_WARRIOR:            // 战士
            case HERO_TYPE.AI_MASTER:             // 法师
            case HERO_TYPE.AI_TANKING:            // 肉盾
            case HERO_TYPE.AI_SHOOTER:            // 射手
            case HERO_TYPE.AI_WIZARD:             // 巫师
            case HERO_TYPE.AI_PARADIN:            // 奶骑
                {
                    pAI = createHeroAI(eCampType);

                    IBehavior pBehavior = null;
                    // 设置IDLE行为
                    pBehavior = new IdleBehavior();
                    pAI.setIdleBehavior(pBehavior);

                    // 设置思考行为
                    pBehavior = new ThinkBehavior();
                    pAI.setThinkBehavior(pBehavior);

                    // 冷却行为
                    pBehavior = new CoolDownBehavior();
                    pAI.setCoolDownBehavior(pBehavior);

                    // 设置攻击行为
                    pBehavior = new AttackBehavior();
                    pAI.setAttackBehavior(pBehavior);

                    // 设置选择策略
                    IChoiceStrategy pChoiceStrategy = createChooseStrategy();
                    pAI.setChoiceStrategy(pChoiceStrategy);
                }
                break;
            default:
                break;
                
        }

        return pAI;
    }
コード例 #14
0
    void Awake()
    {
        // Add event subscription with callback
        GameManager.onGameStartEvent  += EnablePlayer;
        GameManager.onKnightsWinEvent += Celebrate;
        animator      = gameObject.GetComponent <Animator>();
        healthManager = GetComponent <HealthManager>();
        inputManager  = GetComponent <KnightInputManager>();
        soundManager  = GetComponent <SoundManager>();

        // Get Behaviors
        moveBehavior       = GetComponent <MoveBehavior>();
        attackBehavior     = GetComponent <AttackBehavior>();
        blockBehavior      = GetComponent <BlockBehavior>();
        jumpBehavior       = GetComponent <JumpBehavior>();
        takeDamageBehavior = GetComponent <TakeDamageBehavior>();

        //Invoke("Die", 5);
    }
コード例 #15
0
    public void Setup(CharacterSetting characterSetting, CharacterType characterType, Vector2 spawnPos, int direction)
    {
        characterInstance = GameObject.Instantiate(characterSetting.prefab, spawnPos, Quaternion.identity);
        moveBehavior      = characterInstance.GetComponent <MoveBehavior>();
        healthBehavior    = characterInstance.GetComponent <HealthBehavior>();
        attackBehavior    = characterInstance.GetComponent <AttackBehavior>();
        moveBehavior.Setup(characterSetting.speed, direction);
        healthBehavior.Setup(characterSetting.hp);
        switch (characterType)
        {
        case CharacterType.ENEMY:
            characterInstance.gameObject.layer = LayerMask.NameToLayer("Enemy");
            characterInstance.GetComponent <SortingGroup>().sortingLayerID = SortingLayer.NameToID("Enemy");
            attackBehavior.Setup(characterSetting.attack, LayerMask.NameToLayer("Player"));
            break;

        case CharacterType.PLAYER:
            characterInstance.gameObject.layer = LayerMask.NameToLayer("Player");
            characterInstance.GetComponent <SortingGroup>().sortingLayerID = SortingLayer.NameToID("Player");
            attackBehavior.Setup(characterSetting.attack, LayerMask.NameToLayer("Enemy"));
            break;
        }
    }
コード例 #16
0
 public AttackState(NewAI aiBehavior, AITargetObject target, AttackBehavior attackBehavior) : base(aiBehavior)
 {
     this.m_Target         = target;
     this.m_AttackBehavior = attackBehavior;
 }
コード例 #17
0
ファイル: Enemy.cs プロジェクト: jburi/CIS_452_Assignment_3
 //Performs the attack behavior.  Virtual means this method can be overridden by a subclass.
 public virtual void DoAttack()
 {
     AttackBehavior.Attack();
 }
コード例 #18
0
ファイル: PlayerManager.cs プロジェクト: Nodgez/GGJ2016
	void Awake () {
		inputState = GetComponent<InputState> ();
		movement = GetComponent<MoveBehavior> ();
		attack = GetComponent<AttackBehavior> ();
		animator = GetComponent<Animator> ();
	}
コード例 #19
0
 public InvaderAttackState(NewAI aiBehavior, AITargetObject target, AttackBehavior attackBehavior)
     : base(aiBehavior, target, attackBehavior)
 {
     this.m_StateName = "InvaderAttack";
 }
コード例 #20
0
ファイル: Program.cs プロジェクト: PAndy92/StudyOfProgramming
 // AttackBehaviour의 인터페이스를 설정해줌.
 public void SetAttackBehavior(AttackBehavior behavior)
 {
     attackBehavior = behavior;
 }
コード例 #21
0
ファイル: Entity.cs プロジェクト: HotPrawns/Jiemyu
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Entity()
 {
     _AttackBehavior = new AttackBehavior();
     _MoveBehavior   = new MoveBehavior();
     Forward         = new Vector2(0, 1); // Default to facing down
 }
コード例 #22
0
 public void SetAttackBehavior(AttackBehavior attackBehavior)
 {
     this.attackBehavior = attackBehavior;
 }
コード例 #23
0
    private void Figth(HealthBehaviour health)
    {
        AttackBehavior.Attack(health, Idle);

        StateCurrent = State.Figth;
    }
コード例 #24
0
ファイル: UnitAI.cs プロジェクト: roboritch/game-repository
	public void aiAct() {

		//Perform decision making based off of decision parameters decided by overarching AI.
		System.Random random = new System.Random();
		//Check if idle behavior instead of non-idle.
		if(random.NextDouble() < moveIdle) {
			moveDirB = MoveDirBehavior.IDLE;
		} else {
			//Check if offensive movement behavior instead of defensive.
			if(random.NextDouble() < moveDir)
				moveDirB = MoveDirBehavior.TOWARD;
			else
				moveDirB = MoveDirBehavior.AWAY;
		}
		//Check if global movement behavior instead of non-global.
		if(random.NextDouble() > moveGlobalScope) {
			moveScopeB = MoveScopeBehavior.GLOBAL;
		} else {
			//Check if macro movement behavior instead of micro.
			if(random.NextDouble() > moveScope)
				moveScopeB = MoveScopeBehavior.MACRO;
			else
				moveScopeB = MoveScopeBehavior.MICRO;
		}
		//Check if head target behavior instead of body.
		if(random.NextDouble() > moveTarget)
			moveTargetB = MoveTargetBehavior.HEAD;
		else
			moveTargetB = MoveTargetBehavior.BODY;
		//Check if ally target behavior instead of enemy.
		if(random.NextDouble() > moveTeam)
			moveTeamB = MoveTeamBehavior.ALLY;
		else
			moveTeamB = MoveTeamBehavior.ENEMY;
		//Check if macro behavior instead of micro.
		if(random.NextDouble() > attack)
			attackB = AttackBehavior.MACRO;
		else
			attackB = AttackBehavior.MICRO;

		//Possible blocks to attack.
		LinkedList<GridBlock> attackBlocks = getAttackBlocks();
		//Choose the block to attack from attack block list.
		GridBlock attackBlock = chooseAttackBlock(attackBlocks);

		//Check if there's nowhere to attack or enemy is stronger, then move or attack.
		if(attackBlocks.Count == 0 || attackBlock.unitInstalled.getHealthPercentage() > unit.getHealthPercentage()) {
			//Get the list of blocks to move to.
			LinkedList<GridBlock> moveBlockList = getMoveBlockList();

			foreach(GridBlock b in moveBlockList) {
				MoveScript ms = new MoveScript(unit, b);
			}
		} else {
			AttackScript ms = new AttackScript(unit, attackBlock);
		}
	}
コード例 #25
0
ファイル: UnitAI.cs プロジェクト: roboritch/game-repository
	public UnitAI(UnitScript unit) {
		this.unit = unit;

		moveDir = 0.5;
		moveIdle = 0;
		moveScope = 0.5;
		moveGlobalScope = 0.5;
		moveTarget = 0.5;
		moveTeam = 0.5;
		attack = 0.5;

		moveDirB = MoveDirBehavior.IDLE;
		moveScopeB = MoveScopeBehavior.MICRO;
		moveTargetB = MoveTargetBehavior.HEAD;
		moveTeamB = MoveTeamBehavior.ENEMY;
		attackB = AttackBehavior.MICRO;
	}
コード例 #26
0
 public virtual void PerformAttack(ICharacter target)
 {
     AttackBehavior.Attack(this, target);
 }
コード例 #27
0
    public void ConstructBuilding(FindRivalResponseParameter response)
    {
        foreach (BattleRemovableObjectParameter removableObject in response.Objects)
        {
            this.ConstructRemovableObject(removableObject);
        }

        foreach (BattleDefenseObjectParameter defenseObject in response.DefenseObjects)
        {
            this.ConstructDefenseObject(defenseObject);
        }

        if (response.Buffs != null)
        {
            BuildingBuffSystem.Instance.ClearBuff();
            BuildingBuffSystem.Instance.InitialBuff(response.Buffs);
        }

        bool isReplay = Application.loadedLevelName == ClientStringConstants.BATTLE_REPLAY_LEVEL_NAME;
        Dictionary <BuildingType, int> NOGenerater = new Dictionary <BuildingType, int>();

        if (isReplay)
        {
            for (int i = 0; i < (int)BuildingType.Length; i++)
            {
                NOGenerater.Add((BuildingType)i, 0);
            }
        }
        Age  age          = Age.Prehistoric;
        bool isInitialAge = false;
        List <BuildingSurfaceBehavior> notInitialSurfaces = new List <BuildingSurfaceBehavior>();

        foreach (BattleBuildingParameter building in response.Buildings)
        {
            BuildingConfigData configData = ConfigInterface.Instance.BuildingConfigHelper.GetBuildingData(building.BuildingType, building.Level);
            string             prefabName = string.Format("{0}{1}{2}", ClientStringConstants.BATTLE_SCENE_RESOURCE_PREFAB_PREFIX_NAME,
                                                          ClientStringConstants.BUILDING_OBJECT_PREFAB_PREFIX_NAME, configData.BuildingPrefabName);

            GameObject buildingPrefab = Resources.Load(prefabName) as GameObject;
            GameObject buildingObject = GameObject.Instantiate(buildingPrefab) as GameObject;

            buildingObject.transform.position = PositionConvertor.GetWorldPositionFromBuildingTileIndex
                                                    (new TilePosition(building.PositionColumn, building.PositionRow));
            buildingObject.transform.parent = this.m_ParentNode;

            BuildingPropertyBehavior property = buildingObject.GetComponent <BuildingPropertyBehavior>();
            property.BuildingType = building.BuildingType;

            if (building.BuildingType == BuildingType.CityHall)
            {
                this.m_CurrentRivalCityHallLevel = building.Level;
                age          = CommonUtilities.CommonUtilities.GetAgeFromCityHallLevel(building.Level);
                isInitialAge = true;
            }

            if (isReplay)
            {
                property.BuildingNO = NOGenerater[building.BuildingType];
                NOGenerater[building.BuildingType]++;
            }
            else
            {
                property.BuildingNO = building.BuildingNO;
            }
            property.BuildingCategory = (BuildingCategory)configData.Category;
            property.Level            = building.Level;

            property.BuildingPosition     = new TilePosition(building.PositionColumn, building.PositionRow);
            property.BuildingObstacleList = new List <TilePosition>();
            property.ActorObstacleList    = new List <TilePosition>();
            foreach (TilePoint buildingObstacle in configData.BuildingObstacleList)
            {
                property.BuildingObstacleList.Add(buildingObstacle.ConvertToTilePosition());
            }
            foreach (TilePoint actorObstacle in configData.ActorObstacleList)
            {
                property.ActorObstacleList.Add(actorObstacle.ConvertToTilePosition());
            }

            //propert
            property.PlunderRate  = configData.PlunderRate;
            property.GoldCapacity = configData.StoreGoldCapacity;
            property.FoodCapacity = configData.StoreFoodCapacity;
            property.OilCapacity  = configData.StoreOilCapacity;

            property.Buffs = BuildingBuffSystem.Instance.GetBuffs(property.BuildingCategory);

            if (building.CurrentGold.HasValue || building.CurrentFood.HasValue || building.CurrentOil.HasValue)
            {
                property.Gold = building.CurrentGold.HasValue ? building.CurrentGold.Value : 0;
                property.Food = building.CurrentFood.HasValue ? building.CurrentFood.Value : 0;
                property.Oil  = building.CurrentOil.HasValue ? building.CurrentOil.Value : 0;

                property.Gold         = Mathf.RoundToInt(property.Gold * property.PlunderRate);
                property.Food         = Mathf.RoundToInt(property.Food * property.PlunderRate);
                property.Oil          = Mathf.RoundToInt(property.Oil * property.PlunderRate);
                property.OriginalGold = property.Gold;
                property.OriginalFood = property.Food;
                property.OriginalOil  = property.Oil;

                this.m_SceneHelper.AddProduceResourceBuilding(property);
            }
            else
            {
                if ((configData.CanStoreGold && !configData.CanProduceGold && building.Level != 0) ||
                    (configData.CanStoreFood && !configData.CanProduceFood && building.Level != 0) ||
                    (configData.CanStoreOil && !configData.CanProduceOil && building.Level != 0))
                {
                    this.m_SceneHelper.AddResourceBuilding(buildingObject,
                                                           new CapacityConfigData()
                    {
                        GoldCapacity = configData.StoreGoldCapacity,
                        FoodCapacity = configData.StoreFoodCapacity, OilCapacity = configData.StoreOilCapacity
                    });
                }
            }

            BuildingHPBehavior hp = buildingObject.GetComponent <BuildingHPBehavior>();
            hp.TotalHP       = Mathf.Max(1, configData.MaxHP + property.BuffHPEffect);
            hp.SceneHelper   = this.m_SceneHelper;
            hp.ArmorCategory = configData.ArmorCategory;

            if (building.BuilderLevel.HasValue)
            {
                BattleObstacleUpgradingInfo info = new BattleObstacleUpgradingInfo()
                {
                    AttachedBuilderLevel = building.BuilderLevel.Value, ObstacleProperty = property
                };
                this.m_SceneHelper.AddUpgradingObstacle(info);
            }
            if (building.IsUpgrading)
            {
                this.ConstructFacility(buildingObject, property);
            }

            BuildingSurfaceBehavior surface = buildingObject.GetComponent <BuildingSurfaceBehavior>();
            if (surface != null)
            {
                if (isInitialAge)
                {
                    surface.SetSurface(age, building.BuildingType);
                }
                else
                {
                    notInitialSurfaces.Add(surface);
                }
            }

            BuildingAI buildingAI = buildingObject.GetComponent <BuildingAI>();
            if (configData.CanAttack && !building.IsUpgrading)
            {
                buildingAI.enabled = false;
                AttackBehavior attackBehavior = null;
                if (configData.ApMinScope > 0)
                {
                    attackBehavior = buildingObject.AddComponent <RingAttackBehavior>();
                    ((RingAttackBehavior)attackBehavior).BlindScope = configData.ApMinScope;
                }
                else
                {
                    attackBehavior = buildingObject.AddComponent <AttackBehavior>();
                }
                int cd = Mathf.FloorToInt(configData.AttackCD * ClientConfigConstants.Instance.TicksPerSecond);
                attackBehavior.AttackCD       = Mathf.Max(1, cd - property.BuffAttackSpeedEffect);
                attackBehavior.AttackScope    = configData.ApMaxScope;
                attackBehavior.AttackValue    = Mathf.Max(1, configData.AttackValue + property.BuffAttackValueEffect);
                attackBehavior.BulletFlySpeed = configData.AttackMiddleSpeed;
                attackBehavior.AttackType     = (AttackType)configData.AttackType;
                attackBehavior.AttackCategory = configData.AttackCategory;
                attackBehavior.TargetType     = (TargetType)configData.TargetType;
                attackBehavior.DamageScope    = configData.DamageScope;
                attackBehavior.PushTicks      = configData.DamagePushTicks;
                attackBehavior.PushVelocity   = configData.DamagePushVelocity;
                attackBehavior.BulletParent   = this.m_BulletParent;

                buildingAI.AttackBehavior = attackBehavior;
                BuildingIdleState idleState = new BuildingIdleState(buildingAI, true);
                buildingAI.ChangeState(idleState);
                buildingAI.SceneHelper = BattleSceneHelper.Instance;
            }
            else
            {
                buildingAI.DetachSelf();
            }

            this.m_SceneHelper.ConstructBuilding(buildingObject);
        }

        foreach (BuildingSurfaceBehavior surface in notInitialSurfaces)
        {
            surface.SetSurface(age, surface.GetComponent <BuildingPropertyBehavior>().BuildingType);
        }

        this.m_SceneHelper.DistributeResource(response.TotalGold, response.TotalFood, response.TotalOil);


        foreach (BattleAchievementBuildingParameter achievementBuilding in response.AchievementBuildings)
        {
            this.ConstructAchievementBuilding(achievementBuilding, age);
        }
    }
コード例 #28
0
 public BuildingAttackState(NewAI aiBehavior, AITargetObject target, AttackBehavior attackBehavior)
     : base(aiBehavior, target, attackBehavior)
 {
 }
コード例 #29
0
    public string[] tagsToHit;                    //tags that are here can take the effect (dmg or pushforces)


    void Awake()
    {
        attackBehaviour = GetComponent <AttackBehavior>();
    }
コード例 #30
0
 public void Start()
 {
     attackBehavior = GetComponent <SingleShot>();
 }