Inheritance: MonoBehaviour
示例#1
0
    // Start is called before the first frame update



    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
    }
示例#2
0
    void Awake()
    {
        if (I == null)
        {
            I = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        camCtrl      = GetComponent <CameraController>();
        waveCtrl     = GetComponent <WaveController>();
        uiCtrl       = GetComponent <UIController>();
        buildingCtrl = GetComponent <BuildingController>();
        partCtrl     = GetComponent <ParticleController>();
        audioCtrl    = GetComponent <AudioController>();

        foreach (ProjectileType typ in System.Enum.GetValues(typeof(ProjectileType)))
        {
            turretAmmo[typ]         = -1;
            turretReloadTimers[typ] = 0;
        }
    }
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this);
            return;
        }
        instance = this;

        // Set up the dictionary.
        // TODO make this efficient.
        dictionary           = new Dictionary <string, GameObject>();
        ObstacleDamage       = obstacleDamagePrefab.name;
        ObstacleDestroy      = obstacleDestroyEffectPrefab.name;
        ObstacleNegate       = obstacleNegateEffectPrefab.name;
        ProjectileBounce     = projectileBounceEffectPrefab.name;
        PlayerDeath          = playerDeathEffectPrefab.name;
        Explosion            = explosionEffectPrefab.name;
        PlayerLaserCollision = playerLaserCollisionEffectPrefab.name;
        dictionary.Add(ObstacleDamage, obstacleDamagePrefab);
        dictionary.Add(ObstacleDestroy, obstacleDestroyEffectPrefab);
        dictionary.Add(ObstacleNegate, obstacleNegateEffectPrefab);
        dictionary.Add(ProjectileBounce, projectileBounceEffectPrefab);
        dictionary.Add(PlayerDeath, playerDeathEffectPrefab);
        dictionary.Add(Explosion, explosionEffectPrefab);
        dictionary.Add(PlayerLaserCollision, playerLaserCollisionEffectPrefab);
    }
示例#4
0
    public void GenerateTechnique(Agent agent, TechniqueOptions options)
    {
        if (options == null)
        {
            return;
        }
        RuntimeAnimatorController animController = options.animatorController;

        if (animController == null)
        {
            return;
        }
        ParticleController particleController = options.particleController;

        Technique.TechTrigger techTrigger = GenerateTechTrigger(options);

        TriggerTechStrategyOptions[]        triggerStrategyOptions        = options.triggerStrategies == null ? new TriggerTechStrategyOptions[] { ScriptableObject.CreateInstance <NoTriggerOptions>() } : options.triggerStrategies;
        ActivateTechStrategyOptions[]       activateStrategyOptions       = options.activateStrategies == null ? new ActivateTechStrategyOptions[] { ScriptableObject.CreateInstance <NoActivateOptions>() } : options.activateStrategies;
        StateChangeStrategyOptions[]        stateStrategyOptions          = options.stateStrategies == null ? new StateChangeStrategyOptions[] { ScriptableObject.CreateInstance <EndTechStateChangeOptions>() } : options.stateStrategies;
        ActionValidateTechStrategyOptions[] actionValidateStrategyOptions = options.actionValidateStrategies == null ? new ActionValidateTechStrategyOptions[] { ScriptableObject.CreateInstance <NoValidateOptions>() } : options.actionValidateStrategies;
        UpdateTechStrategyOptions[]         updateStrategyOptions         = options.updateStrategies == null ? new UpdateTechStrategyOptions[] { ScriptableObject.CreateInstance <NoUpdateOptions>() } : options.updateStrategies;
        ExitTechStrategyOptions[]           exitStrategyOptions           = options.exitStrategies == null ? new ExitTechStrategyOptions[] { ScriptableObject.CreateInstance <NoExitOptions>() } : options.exitStrategies;

        TriggerTechStrategy[] triggerStrategies = new TriggerTechStrategy[triggerStrategyOptions.Length];
        for (int i = 0; i < triggerStrategyOptions.Length; i++)
        {
            triggerStrategies[i] = triggerStrategyOptions[i].GenerateStrategy();
        }
        ActivateTechStrategy[] activateStrategies = new ActivateTechStrategy[activateStrategyOptions.Length];
        for (int i = 0; i < activateStrategyOptions.Length; i++)
        {
            activateStrategies[i] = activateStrategyOptions[i].GenerateStrategy();
        }
        StateChangeStrategy[] stateStrategies = new StateChangeStrategy[stateStrategyOptions.Length];
        for (int i = 0; i < stateStrategyOptions.Length; i++)
        {
            stateStrategies[i] = stateStrategyOptions[i].GenerateStrategy();
        }
        ActionValidateTechStrategy[] actionValidateStrategies = new ActionValidateTechStrategy[actionValidateStrategyOptions.Length];
        for (int i = 0; i < actionValidateStrategyOptions.Length; i++)
        {
            actionValidateStrategies[i] = actionValidateStrategyOptions[i].GenerateStrategy();
        }
        UpdateTechStrategy[] updateStrategies = new UpdateTechStrategy[updateStrategyOptions.Length];
        for (int i = 0; i < updateStrategyOptions.Length; i++)
        {
            updateStrategies[i] = updateStrategyOptions[i].GenerateStrategy();
        }
        ExitTechStrategy[] exitStrategies = new ExitTechStrategy[exitStrategyOptions.Length];
        for (int i = 0; i < exitStrategyOptions.Length; i++)
        {
            exitStrategies[i] = exitStrategyOptions[i].GenerateStrategy();
        }

        Technique tech = new Technique(agent, options.techniqueName, animController, particleController, techTrigger,
                                       triggerStrategies, activateStrategies, stateStrategies, actionValidateStrategies,
                                       updateStrategies, exitStrategies);

        agent.AddTechnique(tech);
    }
    // Start is called before the first frame update
    void Start()
    {
        particles = GameObject.FindGameObjectWithTag("ParticleController").GetComponent <ParticleController>();
        endLevel  = false;
        //ObjMarkerSingle = ObjMarker.GetComponent<ObjectiveMarker>();

        _phoneUI = GameObject.Find("PopUpPhone").GetComponent <PhoneUI>();
        dataPost = GameObject.FindGameObjectWithTag("Data").GetComponent <DrivePost>();

        Objectives[0].objectiveObject.SetActive(true);
        for (int i = 1; i < Objectives.Length; i++)
        {
            if (Objectives[i].objectiveObject != null)
            {
                //Debug.Log("Turning off " + Objectives[i].objectiveObject.name);
                if (Objectives[0].objectiveObject != Objectives[i].objectiveObject)
                {
                    Objectives[i].objectiveObject.SetActive(false);
                }
            }
        }



        StartCoroutine(GameStartDelay(3));
        foreach (Message m in Objectives[0].messages)
        {
            _phoneUI.SetNotifyMessage(m);
        }
        objectiveCount++;
    }
    public static ParticleController InstantiateParticle(GameObject prefab, float lifetime, Vector2 position, Vector2 velocity, EasingFunction easing)
    {
        ParticleController particle = InstantiateParticle(prefab, lifetime, position, velocity);

        particle.easing = easing;
        return(particle);
    }
示例#7
0
 void Awake()
 {
     if (this.gameObject)
     {
         instance = this;
     }
 }
示例#8
0
    //private GameObject explosionEffect;

    protected override void OnTrigger()
    {
        ParticleController.GetInstance().InstantiateParticle(ParticleController.Explosion, transform.position);

        //Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius, ~(1 << LayerMask.NameToLayer("Environment")));
        //foreach (Collider collider in colliders)
        //{
        //    Rigidbody rb = collider.gameObject.GetComponent<Rigidbody>();

        //    // If this RB has a destructible, it receives damage.
        //    IDestructable destructable = rb.gameObject.GetComponent<IDestructable>();
        //    if (destructable != null)
        //    {
        //        //destructable.ReceiveDamage(CalculateDamage(rb.gameObject));
        //        //continue;
        //    }

        //    // If this is a bullet, the bullet gets destroyed.
        //    Bullet bullet = rb.gameObject.GetComponent<Bullet>();
        //    if (bullet != null)
        //    {
        //        Destroy(bullet.gameObject);
        //    }
        //    //rb.AddExplosionForce(explosionForce, transform.position, explosionRadius);
        //}

        Destroy(gameObject);
    }
示例#9
0
    public Technique(Agent owner, string name, RuntimeAnimatorController animCtrl, ParticleController particleController, TechTrigger techTrgr,
                     TriggerTechStrategy[] triggerStrategy, ActivateTechStrategy[] activateStrategy, StateChangeStrategy[] stateStrategy,
                     ActionValidateTechStrategy[] validateStrategy, UpdateTechStrategy[] updateStrategy, ExitTechStrategy[] exitStrategy)
    {
        if (owner == null || animCtrl == null)
        {
            Debug.LogError("Technique generated with empty arguments");
            return;
        }

        this.name = name;

        this._owner         = owner;
        _techTrigger        = techTrgr;
        _animatorController = animCtrl;
        _particleController = particleController;

        this.triggerStrategies  = triggerStrategy;
        this.activateStrategies = activateStrategy;
        this.stateStrategies    = stateStrategy;
        this.validateStrategies = validateStrategy;
        this.updateStrategies   = updateStrategy;
        this.exitStrategies     = exitStrategy;

        owner.SubscribeToActionEvent(techTrigger.sequence[techTrigger.sequence.Length - 1], OnTrigger);
    }
    float MinimumDistanceAtTime(ParticleController firstParticle, ParticleController secondParticle, float time)
    {
        Vector3 firstEndPos  = firstParticle.getCenter() + firstParticle.getVelocity() * time;
        Vector3 secondEndPos = secondParticle.getCenter() + secondParticle.getVelocity() * time;

        return(Vector3.Distance(firstEndPos, secondEndPos) - firstParticle.getRadius() - secondParticle.getRadius());
    }
 public void AddParticles(ParticleController c)
 {
     c.transform.position = transform.position;
     c.transform.parent   = transform;
     c.gameObject.SetActive(false);
     particles.Add(c);
 }
示例#12
0
    IEnumerator Pattern_7()
    {
        GameObject ins;

        if (!fightFlag)
        {
            FightInitialize();
            fightFlag = true;
        }
        else
        {
            ParticleController Par = GameObject.Find("ParticleController").GetComponent <ParticleController>();
            ins = Instantiate(Par.ParticleRecovery, GameObject.Find("ParticlePanel").transform);
            ins.transform.localPosition = GetPlayer().transform.localPosition;

            GetPlayer().GetComponent <Player>().health += 1;
            GameObject.Find("CurrentHealth").GetComponent <Text>().text = GetPlayer().GetComponent <Player>().health.ToString();
        }


        ins = Instantiate(laodiceaAction, trigTr);
        if (ins != null)
        {
            ins.GetComponent <LaodiceaAction>().SetIdentity(gameObject, 7, Random.Range(1, 5), 1f / (30f - GameController.rank * 1.3f));
            ins.transform.localPosition = new Vector3(-350f, 150f);
        }
        yield return(new WaitForSeconds((30f - GameController.rank * 1.3f) / 3f));

        StartCoroutine("Launch");
    }
示例#13
0
 void OnCollisionExit(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         player = false;
         if (wallUp != null)
         {
             wallUp.kill();
             wallUp = null;
         }
         if (wallDown != null)
         {
             wallDown.kill();
             wallDown = null;
         }
         if (wallLeft != null)
         {
             wallLeft.kill();
             wallLeft = null;
         }
         if (wallRight != null)
         {
             wallRight.kill();
             wallRight = null;
         }
     }
 }
示例#14
0
 void OnEnable()
 {
     _flySpeed           = 5;
     _audioSource        = GetComponentInChildren <AudioSource>();
     _particleController = GetComponentInChildren <ParticleController>();
     _lifeTime           = Time.time + _maxLifeTime;
 }
示例#15
0
 public void OnCollisionEnter(Collision collision)
 {
     if (!Deadly)
     {
         if (collision.collider.gameObject.layer == LayerMask.NameToLayer("Floor"))
         {
             ParticleController.SpawnBreaking(this.transform.position);
             Destroy(this.gameObject);
         }
     }
     else
     {
         if (rBody.velocity.magnitude > 0.75f && collision.collider.gameObject.layer == LayerMask.NameToLayer("Dummies"))
         {
             Dummy tmpDummy = collision.collider.transform.GetComponent <Dummy>();
             if (tmpDummy != null)
             {
                 tmpDummy.Die();
             }
             else
             {
                 Debug.LogWarningFormat("Dummy not found in: {0}", collision.collider.gameObject.name);
             }
         }
     }
 }
    public void InitPool(Dictionary <int, XmlFigure> dic)
    {
        int length = dic.Count;

        figuresPrefab = new Figure[length];
        pool          = new List <Figure> [length];

        for (int i = 0; i < length; i++)
        {
            string path = PREFAB_FOLDER + dic[i].prefab;

            GameObject go = Resources.Load(path) as GameObject;
            figuresPrefab[i] = go.GetComponent <Figure>();

            List <Figure> fList = new List <Figure>();

            for (int j = 0; j < ITEMS_FOR_SPAWN; j++)
            {
                Figure temp = Instantiate(figuresPrefab[i], transform.position, Quaternion.identity, transform);
                temp.InitComponent(i);
                temp.gameObject.SetActive(false);
                fList.Add(temp);
            }

            pool[i] = fList;
        }

        for (int i = 0; i < ITEMS_FOR_SPAWN; i++)
        {
            ParticleController temp = Instantiate(particleObj, transform.position, Quaternion.identity, transform);
            temp.InitParticles();
            temp.gameObject.SetActive(false);
            particles.Add(temp);
        }
    }
示例#17
0
    public override void OnAdvantage(GameObject collider, GameObject other)
    {
        Debug.Log("LASER ADVANTAGE");

        isReflecting = false;

        // If this is a weapon spawn, destroy it.
        if (other.GetComponent <IWeaponSpawn>() != null)
        {
            Destroy(other);
        }

        // If this is a destructible, attempt to inflict damage.
        IDestructable destructable = other.GetComponent <IDestructable>();

        if (destructable != null)
        {
            destructable.ReceiveDamage(DamageCalculator.CalculateByDistance(collider.transform.position,
                                                                            other.transform.position, damageMultiplier));
            ParticleController.GetInstance().InstantiateParticle(ParticleController.PlayerLaserCollision, other.transform.position, transform.position);
            return;
        }

        // Finally, jam the laser if applicable.
        if (charge != null)
        {
            charge.Jam();
            Debug.Log("LASER JAMMED");
        }
    }
示例#18
0
        protected override void BodyGUI()
        {
            base.BodyGUI();
            ParticleController user = (ParticleController)target;

            serializedObject.Update();
            SerializedProperty _particleSystem = serializedObject.FindProperty("_particleSystem");

            SerializedProperty emitPoint     = serializedObject.FindProperty("emitPoint");
            SerializedProperty volumetric    = serializedObject.FindProperty("volumetric");
            SerializedProperty emitFromShell = serializedObject.FindProperty("emitFromShell");
            SerializedProperty scale         = serializedObject.FindProperty("scale");
            SerializedProperty motionType    = serializedObject.FindProperty("motionType");
            SerializedProperty wrapMode      = serializedObject.FindProperty("wrapMode");
            SerializedProperty minCycles     = serializedObject.FindProperty("minCycles");
            SerializedProperty maxCycles     = serializedObject.FindProperty("maxCycles");

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(_particleSystem, new GUIContent("Particle System"));
            if (_particleSystem.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("No particle system is assigned", MessageType.Error);
                return;
            }
            EditorGUILayout.PropertyField(emitPoint);
            EditorGUILayout.PropertyField(volumetric);
            if (volumetric.boolValue)
            {
                EditorGUILayout.PropertyField(emitFromShell);
                EditorGUILayout.PropertyField(scale);
            }
            EditorGUILayout.PropertyField(motionType);
            if (motionType.intValue == (int)ParticleController.MotionType.FollowForward || motionType.intValue == (int)ParticleController.MotionType.FollowBackward)
            {
                EditorGUILayout.PropertyField(wrapMode);
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Path cycles (over " + user._particleSystem.main.startLifetime.constantMax + "s.)", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(minCycles, new GUIContent("Min. Cycles"));
                if (minCycles.floatValue < 0f)
                {
                    minCycles.floatValue = 0f;
                }
                EditorGUILayout.PropertyField(maxCycles, new GUIContent("Max. Cycles"));
                if (maxCycles.floatValue < minCycles.floatValue)
                {
                    maxCycles.floatValue = minCycles.floatValue;
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            if (!Application.isPlaying)
            {
                EditorGUILayout.HelpBox("Particles may not work in the editor preview. Play the game to see the in-game result.", MessageType.Info);
            }
        }
示例#19
0
    public void explode(Vector3 origin, Color color)
    {
        GameObject         explosion           = Instantiate(explosionParticles, origin, explosionParticles.transform.rotation);
        ParticleController explosionController = explosion.GetComponent <ParticleController>();

        explosionController.setColor(color);
        explosionController.play();
    }
示例#20
0
 void Update()
 {
     if (readyToShow && !ParticleController.isShowing())
     {
         StartCoroutine(StartCooldown());
     }
     _isShowing = pointerObject.activeSelf;
 }
示例#21
0
    public override void ExecuteAction()
    {
        Simulation           sim                = Simulation.Instance;
        SimulationController controller         = sim.Controller;
        ParticleController   particleController = controller.GetSimulationComponent <ParticleController>();

        particleController.CreateParticles(_particleActions);
    }
 // Use this for initialization
 void Start()
 {
     OriginPosition     = transform.position;
     OriginScale        = transform.localScale;
     OriginRotation     = transform.rotation;
     particleController = GetComponent <ParticleController> ();
     moveMode           = MoveMode.None;
 }
示例#23
0
    public virtual void Init(RuntimeAnimatorController baseController, ParticleController particleController, int team)
    {
        this.baseController     = baseController;
        this.particleController = particleController;
        this._team = team;

        Init();
    }
示例#24
0
    private void Awake()
    {
        collider = GetComponent <Collider>();

        // we could optionally also make this a singleton
        particleController = FindObjectOfType <ParticleController>();
        camera             = Camera.main;
    }
示例#25
0
    // Use this for initialization
    void Start()
    {
        this.gameObject.SetActive(true);
        anim   = GetComponent <Animator>();
        health = maxHealth;

        partCont = GameObject.FindGameObjectWithTag("ParticleController").GetComponent <ParticleController>();
    }
    public Vector3 getPointClosestToPlane(ParticleController ctrl, Vector3 planeNorm, Vector3 pointOnPlane)
    {
        Plane   plane = new Plane(planeNorm, pointOnPlane);
        Vector3 closestPointOnPlane = plane.ClosestPointOnPlane(ctrl.getCenter());
        Vector3 directionToPoint    = closestPointOnPlane - ctrl.getCenter();

        //Debug.Log("Closes point on plane " + closestPointOnPlane);
        return(ctrl.getCenter() + (directionToPoint.normalized * ctrl.getRadius()));
    }
示例#27
0
    public override void Execute()
    {
        gameObject = (GameObject)GameObject.Instantiate(Particle);
        gameObject.transform.position = CoordinateTransitionToWorld(_Skill.unitController.transform, Position);

        particleController = gameObject.GetComponent<ParticleController>();
        particleController.ExistTime = ExistTime;
        particleController.StartTimer();
    }
示例#28
0
        public Particle(ParticleController controller, ParticleRenderer renderer)
        {
            Controller = controller;
            Renderer   = renderer;

            Angle = Lens.util.math.Rnd.AnglePI();
            Rnd   = Lens.util.math.Rnd.Int(1024);
            T     = Lens.util.math.Rnd.Float(1f);
        }
示例#29
0
    public override void Execute()
    {
        gameObject = (GameObject)GameObject.Instantiate(Particle);
        gameObject.transform.position = CoordinateTransitionToWorld(_Skill.unitController.transform, Position);

        particleController           = gameObject.GetComponent <ParticleController>();
        particleController.ExistTime = ExistTime;
        particleController.StartTimer();
    }
 private void Awake()
 {
     _scoreController = FindObjectOfType<ScoreController>();
     _uiController = FindObjectOfType<UIController>();
     _particleController = FindObjectOfType<ParticleController>();
     
     Enemy.OnEnemyDeath += OnEnemyDeath;
     Player.PlayerDeath += OnPlayerDeath;
 }
示例#31
0
    public void UnbecomeJuggernaut()
    {
        isJuggernaut = false;
        GetComponent <WeaponManager> ().SetAllDamageMults(1f);
        GetComponent <WeaponManager> ().SetAllAttackSpeedReds(1f);
        ParticleController partCont = GetComponentInChildren <ParticleController> ();

        partCont.Stop(4);
    }
示例#32
0
    void Awake()
    {
        if (I == null){
            I = this;
        }else{
            Destroy(gameObject);
            return;
        }

        camCtrl = GetComponent<CameraController>();
        waveCtrl = GetComponent<WaveController>();
        uiCtrl = GetComponent<UIController>();
        buildingCtrl = GetComponent<BuildingController>();
        partCtrl = GetComponent<ParticleController>();
        audioCtrl = GetComponent<AudioController>();

        foreach (ProjectileType typ in System.Enum.GetValues(typeof(ProjectileType))) {
            turretAmmo[typ] = -1;
            turretReloadTimers[typ] = 0;
        }
    }
示例#33
0
 void Start()
 {
     _PC = FindObjectOfType(typeof(ParticleController)) as ParticleController;
     audioSource.clip = attackSound;
 }
示例#34
0
 void Awake()
 {
     instance = this;
 }
示例#35
0
 void Awake()
 {
     Instance = this;
 }
示例#36
0
 void Awake()
 {
     c = GetComponentInChildren<ParticleController>();
 }