コード例 #1
0
        public override void PhysicsProcess(float delta)
        {
            timePassed += delta;
            if (timePassed >= GameValues.treeAddPointsIntervalInSeconds)
            {
                timePassed = 0;
                gameState.AddDemonPoints(GameValues.pointsPerSecondForInfestedTree * treeState.treeGrowth);
            }

            //TODO: show infested state on tree
        }
コード例 #2
0
        private void TargetReached() {
            if (GetNode<Eventing>(Eventing.EventingNodePath).IsConnected(nameof(Eventing.InvalidateDemonPath), this, nameof(OnPathInvalidated))) {
                GetNode<Eventing>(Eventing.EventingNodePath).Disconnect(nameof(Eventing.InvalidateDemonPath), this, nameof(OnPathInvalidated));
            }

            var tileMapObject = pathfindingTileMap.tileMapManipulator.GetTileMapObjectWithTileMapCoordinates(pathfindingTileMap.WorldToMap(targetPosition));
            if (tileMapObject is TreeTileMapObject treeTileMapObject) {
                //TODO: show animation
                gameState.UseDemonEnergy(GameValues.infestTreeEnergyUsage);
                treeTileMapObject.Infest();
                gameState.AddDemonPoints(GameValues.infestTreePoints);
                GetNode<Eventing>(Eventing.EventingNodePath).EmitSignal(nameof(Eventing.TreeInfested), treeTileMapObject);
                soundEngineNode.PlaySfx(infestTreeSound, this, "SfxB");
            }

            GetStateMachine<DemonStateMachine>().TransitionTo(GetStateMachine<DemonStateMachine>().idle);
        }